Skip to navigation
Yoco API

OpenAPI description

Overview

OpenAPI is a specification for describing Representational State Transfer (REST) API interfaces. The OpenAPI Specification (OAS) is both human and machine-readable.

The OpenAPI Description (OAD) represents a formal description of an API and is often published by a service provider as a JSON or YAML file. The description can be used to generate client libraries, documentation, and other tools.

See OpenAPI Specification v3.1.0 and OpenAPI Initiative for more information.

Yoco’s OpenAPI description

A publicly accessible OpenAPI 3.1 description of the REST API is available at https://api.yoco.com/openapi.json.

Using the OpenAPI description

Because the OpenAPI description is machine-readable, there are many publicly available tools that can be used to generate client libraries, documentation, and test API integrations.

Here are some common use-cases:

Generating an API client using OpenAPI Generator

OpenAPI Generator is recommended for generating client libraries.

1

Install using your preferred package manager:

npm install @openapitools/openapi-generator-cli -g
2

Verify openapi-generator-cli is installed:

Command
openapi-generator-cli version
Output
7.16.0
3

List all available generators:

Command
openapi-generator-cli list
Output
The following generators are available:
CLIENT generators:
- ada
- android
- apex
- bash
- c
- clojure
...
4

Generate a client library for TypeScript:

openapi-generator-cli generate -g typescript -o yoco-typescript-client -i https://api.yoco.com/openapi.json
5

The client library is generated in the yoco-typescript-client directory.

6

View the generated README.md file for usage instructions.

Generating a Python API client using openapi-python-client

openapi-python-client is recommended for generating a client library for Python. It’s a more modern alternative that has strong typing, better support for async and leverages Pydantic for data models and validation.

1

Install openapi-python-client generator:

pipx install openapi-python-client --include-deps
2

Generate the client from the OpenAPI description:

openapi-python-client generate --url https://api.yoco.com/openapi.json
3

The client library is generated in the yoco-api-client directory.

4

Make an API call using the generated client:

Note that this is just an example and is not production-ready code. You should never store credentials as plain text in your code.

from yoco_api_client import AuthenticatedClient
from yoco_api_client.api.orders import list_orders_v1_orders_get
from yoco_api_client.models import ErrorResponse, PaginatedResponseOrder
client = AuthenticatedClient(
base_url="https://api.yoco.com",
token="ThisIsAnOAuthAccessToken"
)
with client as client:
response = list_orders_v1_orders_get.sync(client=client)
if isinstance(response, PaginatedResponseOrder):
print(f"Received paginated order response: ", response)
for order in response.data:
print(order.id)
elif isinstance(response, ErrorResponse):
raise Exception(f"Received HTTP status code {response.status}: {response.detail}")