Skip to content

Instantly share code, notes, and snippets.

@mwestwood
Created May 5, 2023 18:15
Show Gist options
  • Save mwestwood/d7eae4c72599709fba9af09c707ecbfc to your computer and use it in GitHub Desktop.
Save mwestwood/d7eae4c72599709fba9af09c707ecbfc to your computer and use it in GitHub Desktop.
Example of api spec

Here's an example of an API endpoint design that takes parameters:

Endpoint: /api/search Method: GET

Description: This API endpoint allows users to search for articles based on specific search criteria.

Parameters:

q (required): A string that represents the search query. category (optional): A string that represents the category of articles to search within. author (optional): A string that represents the author of articles to search for. sort_by (optional): A string that represents the field to sort the results by. Default is relevance. order (optional): A string that represents the order to sort the results in. Default is descending. Example Request:

GET /api/search?q=example&category=technology&author=john&sort_by=date&order=asc
{
  "articles": [
    {
      "title": "Example Article 1",
      "category": "Technology",
      "author": "John",
      "date": "2022-01-01"
    },
    {
      "title": "Example Article 2",
      "category": "Technology",
      "author": "John",
      "date": "2021-12-31"
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment