Skip to content

Latest commit

 

History

History
157 lines (119 loc) · 3.12 KB

overview.md

File metadata and controls

157 lines (119 loc) · 3.12 KB

API overview

The primary goal of this API is not to provide functionality for its users, it was built to be used by the [Tracetest] team as an API to be used in our demo. It's secondary goal is to act as an example of how to instrument REST APIs using OpenTelemetry. So, if you want to understand how to instrument an API using OpenTelemetry, this API might be a good starting point.

Endpoints

This section is reserved to explain how each endpoint work in a more general way.

⚠️ if you want to know more details about requests and responses of each endpoint, take a look at our OpenAPI specification.

GET /pokemon

Description: Get a list of pokemons from the API

Request:

// GET /pokemon?take=20&skip=0

Response:

[
    {
        "id": 25,
        "name": "pikachu",
        "type": "electric",
        "imageUrl": "https://assets.pokemon.com/assets/cms2/img/pokedex/full/025.png",
        "isFeatured": true
    },
    {
        "id": 26,
        "name": "raichu",
        "type": "electric",
        "imageUrl": "https://assets.pokemon.com/assets/cms2/img/pokedex/full/026.png",
        "isFeatured": true
    }
]

Flow:

Get pokemon flow

POST /pokemon

Description: Create a new pokemon

Request:

// POST /pokemon
{
    "name": "meowth",
    "type": "normal",
    "imageUrl": "https://assets.pokemon.com/assets/cms2/img/pokedex/full/052.png",
    "isFeatured": true
}

Successful response:

// 201 Created
{
    "id": 1000,
    "name": "meowth",
    "type": "normal",
    "imageUrl": "https://assets.pokemon.com/assets/cms2/img/pokedex/full/052.png",
    "isFeatured": true
}

Note: the field id is automatically generated. It doesn't match the real id of the pokemon.

Failed response:

// 400 Bad Request
{
    "errors": [
        {
            "property": "name",
            "constraints": [
                "name cannot be empty"
            ]
        },
        {
            "property": "type",
            "constraints": [
                "type cannot be empty"
            ]
        }
    ]
}

Flow:

create pokemon flow

POST /pokemon/import

Description: Import an existing pokemon from PokeAPI and inserts it into the database

Request:

Note:This is import "Persian" into our API)

// POST /pokemon/import
{
    "id": 53
}

Successful response:

{
    "id": 53
}

Failed response:

{
    "errors": [
        {
            "property": "id",
            "constraints": [
                "id must be positive"
            ]
        }
    ]
}

API Flow:

import pokemon flow on API

Worker Flow:

import pokemon flow on worker