Analyze and document the RESTful best practices implemented in each API, including their URL structure, resource naming conventions, HTTP methods usage, error handling, authentication mechanisms, and any other relevant aspects.
The Twitter API can be used to programmatically retrieve and analyze Twitter data, as well as build for the conversation on Twitter. Here’s the V2 of Twitter API -
Authentication flow: Auth 2.0 authentication system
API endpoints:
Tweet lookup endpoints: must be authenticated user
User lookup endpoints:
Follows endpoints:
GET https://api.twitter.com/2/users/:id/followers (followers of user id)
GET https://api.twitter.com/2/users/:id/following (Users a user ID is following)
POST https://api.twitter.com/2/users/:id/following (Follow a user id)
The authorization data will be automatically generated when we send the request
Pre-request script:
// This script extracts the ID of the authenticating user, so you do not have to pass it yourself.
if (!pm.environment.get('access_token') || !pm.request.url.path.includes(':id')) {
return;
}
const [userId] = pm.environment.get('access_token').split('-');
if (!userId) {
return;
}
const userIdIndex = pm.request.url.path.indexOf(':id');
pm.request.url.path[userIdIndex] = userId;
Request body:
{
"target_user_id": "2244994945"
}
DELETE https://api.twitter.com/2/users/:source_user_id/following/:target_user_id (Unfollow a user id)
Blocks endpoints:
Manage tweets endpoints:
Mutes endpoints:
Hide replies endpoints:
PUT https://api.twitter.com/2/tweets/:id/hidden (Hide a reply)
Request body:
{
"hidden": true
}
PUT https://api.twitter.com/2/tweets/:id/hidden (Unhide a reply)
Request body:
{
"hidden": false
}
Search Tweets:
Likes:
POST https://api.twitter.com/2/users/:id/likes (Like a tweet)
Request Body:
{
"tweet_id": "tweet-id-you-want-to-like"
}
GET https://api.twitter.com/2/users/:id/liked_tweets?
DELETE https://api.twitter.com/2/users/:id/likes/:tweet_id
Pre-request script:
// This script extracts the ID of the authenticating user, so you do not have to pass it yourself.
if (!pm.environment.get('access_token') || !pm.request.url.path.includes(':source_user_id')) {
return;
}
const [userId] = pm.environment.get('access_token').split('-');
if (!userId) {
return;
}
const userIdIndex = pm.request.url.path.indexOf(':source_user_id');
pm.request.url.path[userIdIndex] = userId;
Error handling:
{
"title": "Unauthorized",
"type": "about:blank",
"status": 401,
"detail": "Unauthorized"
}
Rate limit:
Every day many thousands of developers make requests to the Twitter API. To help manage the sheer volume of these requests, limits are placed on the number of requests that can be made. These limits help us provide the reliable and scalable API that our developer community relies on.
The maximum number of requests that are allowed is based on a time interval, some specified period or window of time. The most common request limit interval is fifteen minutes. If an endpoint has a rate limit of 900 requests/15-minutes, then up to 900 requests over any 15-minute interval is allowed.
Create a new user account. The email address and username for the account must be unique.
Base URL: https://api.github.com
$ curl -I <https://api.github.com/users/octocat/orgs>
> HTTP/2 200
> Server: nginx
> Date: Fri, 12 Oct 2012 23:33:14 GMT
> Content-Type: application/json; charset=utf-8
> ETag: "a00049ba79152d03380c34652f2cb612"
> X-GitHub-Media-Type: github.v3
> x-ratelimit-limit: 5000
> x-ratelimit-remaining: 4987
> x-ratelimit-reset: 1350085394
> Content-Length: 5
> Cache-Control: max-age=0, private, must-revalidate
> X-Content-Type-Options: nosniff
Endpoints available for GitHub Apps:
**activity:**
GET /events
GET /feeds
GET /networks/{owner}/{repo}/events
GET /orgs/{org}/events
GET /repos/{owner}/{repo}/events
GET /repos/{owner}/{repo}/stargazers
GET /repos/{owner}/{repo}/subscribers
GET /users/{username}/events
GET /users/{username}/events/public
GET /users/{username}/received_events
GET /users/{username}/received_events/public
GET /users/{username}/starred
GET /users/{username}/subscriptions
**actions:**
**branches:**
**commits:**
GET /emojis
GET /gitignore/templates
GET /gitignore/templates/{name}
GET /rate_limit
GET /search/code
GET /search/commits
GET /search/issues
GET /search/labels
GET /search/repositories
GET /search/topics
GET /search/users
The Stripe API is organized around REST. Stripe API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
Base URL: https://api.stripe.com
HTTP status code:
Error types:
Handling error:
API endpoints: