Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CoinMachine API Server

A simple Node.js Express server with public API endpoints.

Features

  • ✅ Simple Express server
  • ✅ Public API endpoints (no authentication required)
  • ✅ CORS enabled for cross-origin requests
  • ✅ JSON responses
  • ✅ Error handling
  • ✅ Development mode with auto-reload

Installation

  1. Install dependencies:
npm install

Running the Server

Development Mode (with auto-reload)

npm run dev

Production Mode

npm start

The server will start on http://localhost:3000 (or the port specified in the PORT environment variable).

API Endpoints

1. GET / - Root endpoint

Returns information about available endpoints.

Response:

{
  "message": "Welcome to CoinMachine API Server",
  "endpoints": {
    "GET /api/status": "Get server status",
    "GET /api/hello?name=YourName": "Say hello",
    "POST /api/echo": "Echo back posted data"
  },
  "timestamp": "2024-01-01T12:00:00.000Z"
}

2. GET /api/status - Server status

Returns the current server status.

Response:

{
  "message": "Server is running!",
  "timestamp": "2024-01-01T12:00:00.000Z",
  "status": "online",
  "version": "1.0.0"
}

3. GET /api/hello - Say hello

Returns a personalized greeting.

Query Parameters:

  • name (optional): The name to greet (defaults to "World")

Example:

GET /api/hello?name=Alice

Response:

{
  "message": "Hello, Alice!",
  "timestamp": "2024-01-01T12:00:00.000Z"
}

4. POST /api/echo - Echo data

Echoes back any JSON data sent in the request body.

Request Body: Any JSON object

Response:

{
  "message": "Data received successfully",
  "data": { "your": "data" },
  "timestamp": "2024-01-01T12:00:00.000Z"
}

Testing the API

You can test the API using curl, Postman, or any HTTP client:

Test server status:

curl http://localhost:3000/api/status

Test hello endpoint:

curl "http://localhost:3000/api/hello?name=YourName"

Test echo endpoint:

curl -X POST http://localhost:3000/api/echo \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello World", "number": 42}'

Environment Variables

  • PORT: The port number to run the server on (default: 3000)

Dependencies

  • express: Web framework for Node.js
  • cors: Cross-Origin Resource Sharing middleware
  • nodemon: Development dependency for auto-reloading (dev mode only)

License

MIT

About

Decentralized monetization of public MCP servers and REST APIs

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages