Skip to main content
Introduction to API Paths section

API Development

Ossi Galkin avatar
Written by Ossi Galkin
Updated over 9 months ago

API Paths section

The second main part of the API definition is the Paths object. The Paths object defines all the relative paths to all Endpoints and their operations that this API offers.

Here is an example of the Paths object containing one path definition and one GET operation for the path:

paths: /now: get: parameters: - name: format in: query description: Format for returned date and/or time required: true schema: type: string responses: '200': description: ok content: application/text: schema: type: string

Object / Item

Description

paths:

The Paths Object holds the relative paths to the individual Endpoints and their operations. The path is appended to the URL from the Server Object (described in the API Header section) to construct the full URL.ull URL.

/now:

This is a Path Item Object that describes the operations available on a single path. If you want to use path parameters, you need to define them here.

Please refer to the Path Item Object documentation.

get:

This is the Operation Object that describes a single API operation on a path. Under one Path Item Object, there can be one or many Operation Objects.

Please refer to the Reference documentation for Operation Object documentation.

parameters: - name: format in: query description: Format for returned date and/or time required: true schema: type: string

Use the parameters section if you want to use parameters. You can define one or many parameters for API operation. Each parameter object includes the following fields:

  • name: Name of the parameter. This is a mandatory field.

  • in: The location of the parameter. Possible values are "query", "header", "path" or "cookie". This is a mandatory field.

  • description: A brief text description of the parameter.

  • required: Determines whether this parameter is mandatory. If the parameter location is "path", this property is REQUIRED and its value MUST be true. Otherwise, the property MAY be included and its default value is false.

  • schema: The schema defining the type used for the parameter.

Please refer to the Parameter Object documentation.

responses:     '200':       description: ok       content:         application/text:           schema:             type: string

The Responses Object documents and defines the possible HTTP response codes of the API operation. It is not necessary to cover all the possible response codes, but it is good practice to cover all successful responses and any known errors.
​
Please see the Responses Object documentation for details and further examples.

When defining REST APIs with OpenAPI Specification, it is recommended to follow common guidelines for REST Status Codes. For details, please read, for example, "The Complete Guide to Status Codes for Meaningful REST APIs.

Did this answer your question?