MyApp API Guide

API Overview

Welcome to the MyApp REST API. This guide provides details on how to interact with our service programmatically.

All endpoints are served over HTTPS and return JSON payloads.

Authentication

MyApp uses Bearer Token authentication. Include the token in the Authorization header:

Authorization: Bearer YOUR_ACCESS_TOKEN
Token Retrieval Flow
  1. Register your application at Dashboard.
  2. Obtain a client ID and secret.
  3. Request a token via POST /oauth/token with grant_type=client_credentials.
  4. Store the token securely; it expires after 24h.

Endpoints

Method Endpoint Description
GET /api/v1/users List all users
GET /api/v1/users/{id} Retrieve a single user
POST /api/v1/users Create a new user
PUT /api/v1/users/{id} Update user information
DELETE /api/v1/users/{id} Delete a user
GET /api/v1/orders List all orders
GET /api/v1/orders/{id} Retrieve order details

Error Handling

The API uses standard HTTP status codes. Errors are returned in the following JSON format:

{
    "error": {
        "code": "INVALID_REQUEST",
        "message": "The request payload is malformed.",
        "details": [
            {"field":"email","issue":"Invalid format"}
        ]
    }
}

Request Example (cURL)

curl -X GET "https://api.myapp.com/api/v1/users" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"

Response Example

{
    "data": [
        {
            "id": "123",
            "name": "Jane Doe",
            "email": "jane@example.com",
            "created_at": "2023-07-14T12:34:56Z"
        },
        {
            "id": "124",
            "name": "John Smith",
            "email": "john@example.com",
            "created_at": "2023-07-15T09:20:11Z"
        }
    ],
    "meta": {
        "total": 2,
        "page": 1,
        "per_page": 20
    }
}