OpenAPI specificationInstagram APIAPI reference· 15 min read

Instagram API OpenAPI Specification: Endpoints and Errors

Find the Instagram API OpenAPI specification: spec URL, endpoint groups, request parameters, response schemas, error codes and credit charges, with setup steps.

Instagram API OpenAPI Specification: Endpoints and Errors

You have the key in an environment variable, a curl command that returns JSON, and a dashboard that says the integration is live. Then someone asks why one account's engagement rate looks stale and why last week's build burned through twice the credits. The answers are sitting in the openapi specification file, not in the dashboard. Most developers treat that file as documentation: open it once, skim the paths, and go back to guessing at field names and error codes. It's a contract, and a contract gets verified against what comes back. What follows is where each part of this document lives, what to check before you write a line of client code, and which assumptions about errors and credit charges break first.

Table of Contents

Quick Reference for the Instagram API Spec

Item Value
Spec location api.profilequery.com/openapi.json
Base URL api.profilequery.com/v1
Authentication Bearer API key in the Authorization header
Login or app approval None: no OAuth, app review or Business Verification
Request and response format JSON in, JSON out
OpenAPI version of the document OpenAPI 3.x (read the openapi field to confirm which)

The spec location is a machine-readable document you import into tools, not a prose page you read once. Every path in it is relative to the base URL, so a path such as /profile resolves to the full base plus path.

Authentication is a static key in an Authorization: Bearer header. No OAuth handshake, no app review queue, no Business Verification step, which is the part that surprises developers arriving from Meta's own Graph surface.

Requests and responses are JSON in, JSON out, so one content type covers both directions and generated clients don't need separate serializers. The document itself is an OpenAPI 3.x description, and the openapi string near the top drives every tool choice below.

Treating the file as an integration contract rather than a reference page is the same discipline Stripe developers at Continuum Solutions apply to payments: the spec is what the client is generated from, so it gets read, versioned and checked.

How to Download and Load the Specification

The document is a plain GET away, and nothing stands between you and it. Save a copy next to your client code rather than fetching it at build time, because a pipeline that downloads the spec on every run produces different clients when the file changes mid-sprint.

A three-step infographic showing how to identify and compare OpenAPI specification versions 3.0 and 3.1.

  1. Fetch and save it. Send a plain GET request to the spec URL and write the response body to openapi.json. No login step, no OAuth dance.
  2. Confirm it parses. Run jq . openapi.json or open it in an editor with JSON validation. A saved HTML error page behind a redirect is the most common reason an import fails later with a cryptic message.
  3. Browse it in Swagger UI or Redoc. Drop the file into either renderer and you get every operation with its parameters and response schemas laid out, which beats scrolling raw JSON on a first pass.
  4. Import it into Postman. Postman builds a collection from the document. Store the API key as a collection variable and reference it in the collection's auth tab, so generated requests inherit it and nothing gets retyped per call.

The format itself started life as the Swagger Specification, first released in 2011, and was renamed the OpenAPI Specification on January 1, 2016 after the OpenAPI Initiative took over governance (OpenAPI Initiative FAQ). That vendor-neutral lineage is why nearly every tool in this chain can read the file without a converter.

If you'd rather watch the setup before running it, this walkthrough covers importing a spec and sending the first authenticated request.

  1. Generate a typed client. Point an SDK generator at the file and read the output before shipping it. Regenerate after each spec change instead of hand-patching generated code.
  2. Register it with an agent tool loader if an AI assistant calls the API. ChatGPT Actions and LangChain read the operation descriptions to decide which call fits a request, so the descriptions matter as much as the schemas.
  3. Send one real request. Call a path under the base URL with the key in an Authorization: Bearer header and confirm you get JSON fields back rather than an authentication error.

Store the key as a variable, not a constant

The slip that costs people real money is pasting the key into the spec file's security section or into a saved Postman environment, then committing the file. Keep the key in an environment variable and let the tooling inject it. Success looks unglamorous: a 200 with the fields you expected, a request identifier in the body, and a credits figure that matches your balance.

Read the OpenAPI Version and Check Tool Support

The first field to read is openapi, near the top of the file. It's a version string, and it tells you which keyword vocabulary the schemas use before you point any generator at them.

The official specification index lays the chain out: OpenAPI 3.0.0 arrived on July 26, 2017 with reusable components, server definitions, request bodies and callbacks; 3.1.0 followed on February 15, 2021 and aligned its schema vocabulary with full JSON Schema Draft 2020-12 compatibility; 3.0.4 and 3.1.1 both landed on October 24, 2024. The OpenAPI Initiative's September 2025 newsletter records 3.1.2 that month, and 3.2.0's arrival with the QUERY method, sequential and streaming protocols and OAuth 2.0 Device Authorization Flow.

A five-step infographic explaining how to identify your OpenAPI specification version and verify tool compatibility.

A document can be valid and still be unreadable by your toolchain. Validity and support are different questions.

  1. Compare the string against your tools. Check the versions your generator and renderer document as supported, not the ones their landing page implies.
  2. Generate one small client and read the output. A model that compiles but drops a nullable field tells you more than any compatibility table.
  3. Pin generator and renderer versions in your project file. An unpinned generator can change method names overnight.
  4. Don't assume a newer document is fully understood downstream. Some tools ignore unfamiliar keywords without a warning, which is exactly why version pinning belongs in the same commit as any regeneration.

Security testing tools read the same document to enumerate attack surface, so a version your scanner can't parse is a blind spot as well as a codegen problem. ThreatExploit AI on API exploitation risks covers what that surface looks like once it's mapped.

Find Operations, Parameters and Typed Errors in the Spec

Each operation is one entry under its path, and that entry lists everything a request needs. Open the file in Swagger UI or Redoc, expand an operation, and read four parts in order.

  1. The parameters list. For each parameter, note its name, whether it lives in the path or the query string, its type, its allowed values and whether it's required.
  2. The request body, where one exists. A GET on this API won't have one, but a search endpoint may take filters that behave differently from path parameters.
  3. The responses list. Find the success status code and each error case, then follow the schema reference attached to it. That reference is where typed error codes live.
  4. The security requirement. Confirm it names the Bearer scheme. A key sent under a different header name won't match the declaration, and the request fails before reaching your handler.

Record the operationId too, because generators turn it into a method name. Renaming or regenerating against a changed operationId breaks every caller in your codebase.

If paths, operations and response objects aren't second nature yet, this explanation of what a REST API is covers the model the document assumes.

Once you've read the four parts, write them into a short table per operation in your own notes: parameter name, location, required flag, and the error codes you'll branch on. That table is what stops you guessing at a parameter name at 6pm.

Handling three identifier forms for one account is the same class of problem as name matching across state registries at SOSfinder: you need one canonical key before you compare records, or duplicates slip through. Decide which identifier form your code treats as canonical before you write the request layer.

Endpoint Groups and Which One Fits Your Task

Group Endpoints covered
Profile Profile details, posts, reels, stories, highlights, followers, following
Account transparency Creation month and year, account age, registration country, previous usernames, verification status
Posts and comments Individual post, comments, likers
Hashtags Top posts, recent posts
Locations Location details, location posts
Search User search, hashtag search, location search
Insights Engagement rate, best time to post, account stats, fake-follower audit, lead fit scoring, profile summary, niche classifier

Read that table as a menu, not a map. The profile group is the widest: account details, posts, reels, stories, highlights, followers and following, all reachable by username, numeric identifier or profile URL.

Account transparency answers a different question entirely. Creation month and year, account age, registration country, previous usernames and verification status all sit here. Registration country is not current residence, and treating them as the same field produces compliance decisions you can't defend.

The middle groups are narrower:

  • Posts and comments: a single post, its comment thread, and the accounts that liked it.
  • Hashtags: top posts and recent posts for a tag.
  • Locations: location details plus posts attached to that place.
  • Search: user, hashtag and location lookup to resolve an identifier before you call anything else.

Computed scores versus measured fields

The insight endpoints deserve their own namespace in your code. Engagement rate, best time to post, account stats, fake-follower audit, lead fit scoring, profile summary and niche classifier return computed judgements, not measured values. Keep them separate from raw counts so nobody downstream quotes a score as an observation.

Rule of thumb: if a number has to survive an audit, start from transparency fields and raw counts, not from a score.

Matching groups to the job is where teams go wrong first:

  1. Client generation: start from the document itself, then run the validation checks in CI so a schema change fails the build rather than the app.
  2. Brand and creator tracking: profile, posts and hashtag endpoints do the work. Pull the account once, then poll the content endpoints.
  3. Trust and safety review: account transparency plus the fake-follower audit. Cross-check verification status against registration country before you flag anything.
  4. AI agents: every endpoint is exposed as an MCP tool, so Claude Code, Claude Desktop, Cursor and agent frameworks can call the API conversationally. Confirm each operation you rely on appears in the document before wiring it into a tool manifest.

Sign up for a free key on the Instagram API site before testing any group. No approvals, no OAuth flow.

Request Parameters and Authentication Headers

Every call goes to a path under the base URL and carries the key in exactly one place: Authorization: Bearer <key>. No session, no token refresh, no cookie. That single requirement is also the single point of failure.

Profile endpoints accept three identifier forms: a username, a numeric identifier, or a profile URL. They resolve to the same account, which is convenient until you mix two forms in one request and get a validation error instead of a profile.

The mistake that shows up most often is sending the key as a query string, ?api_key=..., or under a made-up header such as X-API-Key. Neither matches the security scheme the document declares, so the request fails with a typed error before any data is touched.

Keep the key in the header and nowhere else. A key in a URL ends up in proxy logs, browser history and shared screenshots.

A three-item pre-flight catches most of this:

  • Required parameters present: every parameter the operation marks required, with the exact spelling from the spec.
  • One identifier form per request: pick username or URL or numeric ID, never two.
  • Key in the header only: verify the header name matches the security scheme, character for character.

Then run the test that settles it. Send the same account once by username and once by profile URL, and compare the returned account details. If both resolve to the same profile with the same fields, identifier handling works and either form is safe in production. If they diverge, you have a normalization bug to fix before anything is cached.

For the broader pattern of key handling, rotation and header hygiene, this guide to API key authentication covers the parts that apply to any bearer-token service.

Response Schemas and Metadata Fields

Every endpoint returns JSON in a consistent envelope, and the schema attached to each response defines each property, its type, whether it's required, whether it can be null, and how arrays are represented.

Schema meaning depends on the dialect, and that matters more than it sounds. The specification defines an OpenAPI Schema Object dialect that combines the OpenAPI base vocabulary with vocabularies from the JSON Schema Draft 2020-12 general-purpose meta-schema, so tooling has to identify whether a schema targets JSON Schema Core, JSON Schema Validation, the OpenAPI dialect or a custom meta-schema (OpenAPI Specification). Setting jsonSchemaDialect at document level gives validators and generators one consistent default; $schema on an individual schema overrides it where you need explicit selection. Skip both and a validator, a code generator and a doc renderer can read the same profile schema under different keyword rules.

Metadata field What it reports How to use it in code
Request identifier Unique ID for this request Log it so support can trace a specific call
Credits charged Credits deducted for the call Track per-endpoint cost: one for most requests, two for deeper endpoints
Remaining balance Credits left on the account Alert before the balance runs out
Processing time Time the request took Set timeouts and compare speed across endpoint groups

Treat those four fields as operational data, not decoration. Log the request identifier on every call, run a monitoring job that compares remaining balance against your expected burn rate, and use processing time per group to set client timeouts instead of picking one global number.

Handle absence before it becomes a crash

Public profiles omit fields. A private or sparse account may return no email-like contact data, no follower history, or a null where your sample had a string. Mark every non-required property as possibly absent and every nullable one as possibly null in your model, so a thin profile returns a partial object rather than throwing a deserialization error in a batch job.

Where the API applies constraints the schema can't express, such as a maximum page size, document them in descriptions and vendor extensions rather than relaxing the schema. The contract should say what's true, including the limits.

Error Codes, Typed Errors and Charging Rules

Errors come back typed. Branch on the code value, never on the message text, because message wording changes and codes don't.

The case worth memorizing is invalid_api_key, returned when the key is invalid or has been revoked. That's a configuration problem, not a transient one.

Situation Error code or response Charged? What to do
Invalid or revoked API key invalid_api_key No, no data is queried Replace the key; do not retry the same request
Invalid input Typed validation error from the operation's responses No Fix the identifier before resending
Upstream provider failure Typed upstream error from the operation's responses No Retry after a short wait
Documented not-found response Not-found response Yes, when Instagram was queried Count it as a billable result in budgets

The charging rules are the part teams underestimate. Invalid input isn't charged, and neither are upstream provider failures, so retrying the latter after a brief wait costs time and nothing else. A documented not-found response can still incur charges when Instagram was queried, so a missing account is a billable result rather than a free miss. Budget for it in the same line as successful calls, or your monthly reconciliation will never balance.

Never retry an invalid key or a rejected identifier. Both fail identically on the second attempt, and one of them spends time you could use fixing the input.

Read the error responses per operation rather than sampling one and assuming the rest match. The document lists error cases operation by operation, and that's where the exact codes for validation and upstream failures live. Fill those into your own notes before you write retry logic.

Check the Spec Against Live Responses

A spec is a claim, and claims drift. APIContext reported in 2024 that almost 30% of the production APIs it tested did not match their published OpenAPI descriptions (APIContext API drift white paper). Assume your endpoints are in the other 70% and prove it.

  1. Validate the document itself against the official OpenAPI schema on every build, so a malformed file fails before codegen runs.
  2. Send representative requests to each endpoint group and compare the payload to the schema attached to that operation.
  3. Confirm required fields appear. A field marked required that's missing in production is a contract violation, not a rendering quirk.
  4. Check nullability and array shapes against real responses, including a sparse profile and an account with a large follower count.
  5. Verify error responses use the documented codes, including invalid_api_key with a deliberately revoked key in a staging environment.
  6. Rerun everything whenever the spec changes, and treat a spec change as a code change with the same review path.

The continuous-integration pattern that works is boring: run the validator on every build, replay a saved fixture set against each group, and fail the build when a response doesn't match its endpoint schema. Store the spec URL as the single reference the team checks against, and validate each response against its endpoint schema before you persist it, so drift gets caught at the point of use rather than three weeks later in a report.

Mismatches cluster in three places: optional fields that disappear, nullable values that arrive as missing keys, and error bodies that carry a different shape than the success envelope. Those three are what your fixtures should cover first.

If your client is written in Python, this guide to calling an API from Python covers the request layer these checks sit on top of. A passing run for every endpoint group is the signal that the document is safe to generate clients from.


Instagram API puts the entire surface in one importable document: profiles, account transparency, posts, hashtags, locations, search and insight endpoints, with typed errors, per-call credit metadata and a bearer key instead of an OAuth flow. Pull the openapi specification into your generator, then run the drift checks above against live responses before you ship a client anyone depends on. Get a key at Instagram API and load the document into your toolchain today.

Pull Instagram data with one API call

Profiles, posts, reels, followers and more. 50 free credits, no credit card.

Get your free key