Definition

What is an API endpoint?

An API endpoint is a point at which an application programming interface -- the code that enables two software programs to communicate with each other -- connects with the software program. APIs work by sending requests for information from a web application or web server and receiving a response.

In other words, API endpoints are the specific digital location where requests or API calls for information are sent by one program to retrieve the digital resource that exists there. Endpoints specify where APIs can access resources and help guarantee the proper functioning of the incorporated software. An API's performance depends on its capacity to successfully communicate with API endpoints.

Software programs typically have multiple API endpoints. For example, Instagram's endpoints include one that enables businesses and creators to measure media and profile interactions, another that lets them moderate comments and their replies, and a third that enables them to discover hashtagged media.

A diagram of an API showing how it works.
APIs facilitate seamless data flow between software programs.

Why are API endpoints important?

APIs have various use cases and are important for the following reasons:

  • Communication between systems. API endpoints serve as the specific digital locations where client requests for information are sent by one program to retrieve the digital resource that exists there. They're the points at which the client and the server communicate, enabling two applications to share resources.
  • Proper functioning of software. API endpoints ensure that the software interacting with the API is functioning correctly. They're crucial to API success and help find the exact location of the resources to be accessed by the API.
  • Access to resources. Endpoints designate where APIs can access resources and help guarantee the proper functioning of the incorporated software. For example, they're how the API can access the resources they need from a server to perform their task.
  • Integration and interactions. API endpoints are important because they help point out the specific location of the resources that need to be accessed and ensure the software works with the API as designed. They're also critical for programs to work, as they facilitate communication between different systems.
  • Testing and automation. Automated testing for API endpoints, along with monitoring of API design, is essential for ensuring the proper functioning of APIs. API endpoints are important for setting up automated API testing in continuous integration/continuous delivery pipelines to run tests on endpoints before a release.
  • Ease of use and documentation. Properly defined API endpoints with clear documentation can make it easy for developers to understand and integrate with an API. The API documentation typically describes each endpoint, its parameters, expected responses and usage examples, reducing the learning curve for developers.

How API endpoints work

Systems that communicate through APIs are integrated systems. API endpoints are specific endpoint URLs within a web application that are used to interact with the functionalities provided by that application.

One side of the API connection sends the information to the API and is called the server. The other side, called the client, makes the requests and manipulates the API. The server side that provides the requested information, or resources, is the API endpoint.

For an effective request to be processed by the endpoint, the client must provide a URL, method, list of headers and body.

The headers provide metadata about a request, and the body holds the data sent by the client to the server.

Endpoints work in tandem with API methods. Methods are permitted requests that can be made, such as GET, DELETE, PATCH or POST. Methods -- often called verbs in communications syntax -- are often placed just before the specified endpoint in a full URL.

How are API endpoints and clients authenticated?

APIs use authentication methods to verify the identity of users or applications trying to access the API. The following are common methods of authenticating API endpoints and clients:

  • API keys. An API key is like a unique ID card granting users access to an API. Clients can access them to authenticate the application initiating the request, rather than the individual user.
  • Open Authorization. OAuth is a popular authorization framework that enables secure delegation of user access. It involves a three-party interaction: the API provider, the API client (app requesting access) and the resource owner (user). OAuth offers a more secure way to manage access tokens than API keys.
  • HTTP Basic authentication. This method transmits usernames and passwords directly within the API request. While convenient, it isn't the most secure option because the credentials are encoded using a basic algorithm that can potentially be decoded. It's generally recommended only when used in conjunction with HTTPS or encrypted communication for added API security.
  • JavaScript Object Notation Web Tokens. JWTs are self-contained tokens that contain information about the user and their permissions. The API client securely transmits the JWT to the API server, which can then validate the information within the token to grant access. JWTs offer an advantage, as they eliminate the need for the API server to maintain session data.
  • Mutual Transport Layer Security. TLS is the protocol that creates an authenticated connection between client and server when loading webpages. It can also authenticate both sides of an API integration.

Examples of API endpoints

API endpoints can vary widely depending on the service or platform to which they belong. For example, the code used to place a request for a specific statistics page on the National Basketball Association's website might read as follows:

GET https://stats.nba.com/stats/allstarballotpredictor

In this example, GET is the method, while the endpoint is the specific portion of the web address noted as /stats/allstarballotpredictor. If, on the other hand, an application is requesting information from Amazon's DynamoDB service, its request might read https://dynamodb.us-west-2.amazonaws.com.

Consider the Instagram example further: If a Meta developer wanted to request metrics on an Instagram Business or Creator account, they could use the Instagram Graph API to query the Instagram metrics endpoint. The request might look like the following:

GET graph.facebook.com/17841405822304914/insights
             ?metric=impressions,reach,profile_views
             &period=day

The following are some real-world examples of API endpoints from different platforms.

X (formerly known as Twitter) API

Endpoint: https://api.twitter.com/1.1/statuses/user_timeline.json

Description: Returns a collection of the most recent tweets posted by the user specified by the "screen name" or "userid" parameters.

GitHub REST API

Endpoint: https://api.github.com/users/{username}

Description: Retrieves information about a specific GitHub user.

YouTube API

Endpoint: https://www.googleapis.com/youtube/v3/search

Description: Returns a list of search results that match the specified query parameters.

Google Maps API

Endpoint: https://maps.googleapis.com/maps/api/geocode/json

Description: Converts addresses into geographic coordinates, such as latitude and longitude, and vice versa.

How to test API endpoints

It's important to test the API endpoints to ensure their functionality, user experience and performance. When discussing web APIs, the focus typically centers on representational state transfer (REST) APIs, which use HTTP methods to direct the API on which actions to take.

The four most common HTTP methods in API requests are as follows:

  • GET. GET retrieves a resource.
  • POST. POST creates a resource.
  • PUT. PUT updates an existing resource.
  • DELETE. DELETE removes a resource.

Common methods of API testing include the following:

  • Manual testing. API endpoint testing can be conducted manually by sending requests to the endpoint using testing tools or directly from the browser. The manual testing approach lets testers interact with the API and observe its responses for different scenarios.
  • Unit testing. Unit testing focuses on confirming that a single endpoint returns the correct response to a given request. It can involve validating how the endpoint handles optional parameters, error messages and other specific scenarios.
  • Automated testing. Automated testing involves using tools and scripts to send requests to API endpoints and validate the responses. Automation provides simplicity and high accuracy and can be used as a quality gate in the development pipeline.
  • End-to-end testing. End-to-end testing validates key user journeys that involve multiple endpoints and APIs. It helps pinpoint issues in complex workflows before users encounter them.
  • Access control and authorization testing. It's important to test API endpoints for access control and authorization. This involves verifying that the API enforces proper authentication and authorization mechanisms.

    Discover how enterprises use APIs to improve customer and partner interactions. Discover the ideal API types to meet specific business needs.

    This was last updated in July 2024

    Continue Reading About What is an API endpoint?

    Dig Deeper on API design and management

    Software Quality
    Cloud Computing
    TheServerSide.com
    Close