Accessing Open API Endpoints
To import data from open API endpoints into Excel, follow these steps:
- Open Excel and create a new workbook.
- Go to the "Data" tab and click on "Get Data" > "From Other Sources" > "From Web".
- In the "From Web" dialog box, enter the URL of the JSON API and click "OK".
- The JSON data will load into the Power Query Editor. Select "Parse" > "JSON", then choose "To table" and click "OK".
- Apply any necessary transformations and click on "Close & Load" to import the data into Excel.
Accessing Secure API Endpoints with Authentication
For secure API endpoints requiring a token, use the following method:
- Open Excel and create a new workbook.
- Access Power Query by going to the "Data" tab, then "Get Data" > "From Other Sources" > "Blank Query".
- Enter the Power Query Editor and input the code to access your secure API, including the API token in the request headers. For example:
- Parse the JSON data, apply necessary transformations, and then load it into Excel by clicking "Close & Load".
let
url = "your_api_endpoint",
headers = [Authorization="Bearer your_token"],
source = Json.Document(Web.Contents(url, [Headers=headers]))
in
source
Authentication for Secure Endpoints
To ensure secure access to the API, we employ token-based authentication. Follow these steps:
- Obtaining Your Access Token: Send a
POST
request to/api/token
with your credentials. - Using Your Access Token: Include the token in the
Authorization
header for API requests. - Token Expiry: Tokens are valid for a limited time. After expiry, re-authenticate for a new token.
- Example of an Authenticated Request: Make authenticated requests like this:
- Handling Authentication Errors: For
401 Unauthorized
errors, check your credentials and token validity.
GET /api/resources
Authorization: Bearer YOUR_ACCESS_TOKEN