This repository has been archived by the owner on Aug 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(apis): Adding API basics (#1027)
* docs(apis): Adding API basics * Apply suggestions from code review apply suggested changes Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com> --------- Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com>
- Loading branch information
1 parent
91d9fde
commit 3c04c0b
Showing
6 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: "REST API Basics" | ||
sidebar_order: 1 | ||
--- | ||
This section includes common terms and resources to learn more about API design. If you're new to API design, this is a good place to start. | ||
|
||
## Common Terms | ||
- **Resource** is the object you’re performing the action on with your endpoint. For example, in ProjectEndpoint the resource is Project. | ||
- **Resource Identifier** can be an ID, like an event ID, or slug, like an organization slug. Note that it must be unique. For example, Sentry's project resource identifier is {org_slug}/{project_slug}, because projects are only unique within their organization. You can find more information about this in the slug vs. ID section. | ||
- **Method** is what you do with the resource. Each endpoint can have multiple methods. For example in ProjectEndpoint, you can have a GET method that returns details of a specific project. | ||
- **Collection** is basically an object type. You can map them to a Django object type like an Organization or a text object like an error. | ||
|
||
## Extra Resources | ||
The following resources are helpful to learn about general API design best practices: | ||
|
||
- **[The Design of Web APIs](https://g.co/kgs/R7rXEk)** is an example-packed guide to designing APIs. | ||
- **[API Design Patterns](https://g.co/kgs/Vfnpe5)** is comprehensive guide on key API patterns. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: "Designing a New API" | ||
sidebar_order: 2 | ||
--- | ||
Here are some considerations to make when designing new Sentry APIs. | ||
|
||
## URL Patterns | ||
The API's URL is what developers use to call the endpoint so it’s important that it is meaningful and clear. | ||
|
||
### Don't Exceed 3-level Nesting | ||
Nested resources format like `api/0/organizations/{org}/projects/` is recommended over `api/0/projects/` for readability because it gives user an understanding of resource hierarchy. However, nesting can make URLs too long and hard to use. Sentry uses 3-level nesting as a hybrid solution. | ||
|
||
Here are some possible urls for values with this resource hierarchy: organization -> project -> tag -> value | ||
- 👍 `/projects/{organization_slug}/{project_slug}/tags/{tag_id}/values` | ||
- 👎 `/organizations/{organization_slug}/projects/{project_slug}/tags/{tag_id}/values/` | ||
- 👎 `/values/` | ||
|
||
In the above example we flattened `projects`. The table below shows the existing flattened collections which works out with our existing APIs. | ||
|
||
| First collection in URL | When to use | Parent | Identifier | Example | | ||
| --- | --------- | ----- | --- | --- | | ||
| organizations | When the resource cannot be attached to any other collection below parent like Project | N/A - always comes as first collection | {organization_slug} | [Create a New Team](https://docs.sentry.io/api/teams/create-a-new-team/) | | ||
| teams | When the resource is under a specific team in the hierarchy | organizations | {organization_slug}/ {team_slug} | [Retreive Team Stats](https://docs.sentry.io/api/teams/retrieve-event-counts-for-a-team/) | | ||
| projects | When the resource is under a specific project in the hierarchy but not under an issue | organizations | {organization_slug}/ {project_slug} | [Create a New Client Key](https://docs.sentry.io/api/projects/create-a-new-client-key/)| | ||
| issues | When the resource is under a specific issue in the hierarchy | projects | {issue_id} | [List an Issue's Events](https://docs.sentry.io/api/events/list-an-issues-events/)| | ||
| sentry-app-installations | When the resource is mapped to a specific integration | organizations | {integration_slug} | [Delete an External Issue](https://docs.sentry.io/api/integration/delete-an-external-issue/)| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
title: 'Making an API Public' | ||
sidebar_order: 4 | ||
--- | ||
|
||
## Introduction | ||
|
3c04c0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
develop – ./
develop-git-master.sentry.dev
develop.sentry.dev