How to autocomplete variables in API Spector

Roy de Kleijn Roy de Kleijn · · 2 min read
How to autocomplete variables in API Spector

Variables keep requests portable: {{baseUrl}}, {{token}}, and the like resolve differently per environment. API Spector completes them as you type, so you do not have to remember exact names or where each one is defined.

Trigger it with two braces

Type {{ in almost any field and a dropdown opens with every variable in scope. Keep typing to filter the list, then press Enter or click to insert. Matching is by name, so {{ba narrows to baseUrl and anything else that starts with "ba".

Where it works

The dropdown appears in the fields and editors you use most:

  • The URL bar.
  • Header and query parameter rows, both the key and the value.
  • The Auth tab: bearer token, API key name and value, and the username and password for Basic, Digest, and NTLM.
  • The request body, whether raw, JSON, or XML.
  • Data table cells, so a data driven run can reference a variable per row.
  • Pre request and post response scripts, where it also completes the sp.* scripting API, the assertion helpers, and faker.

Every source in one list

The list merges every place a variable can come from: environment variables, including ones inherited from a parent environment, collection variables, variables a script set with sp.*.set(), data table columns, and session and global values. Dynamic values such as $randomUUID and $timestamp are offered too, so you can drop a generated value straight into a request.

See the value before you send

Hovering a {{variable}} in an editor shows the value it resolves to right now, using the active environment. That is a quick way to confirm an environment is selected and a token is set before you send.

Why it helps

Typing a variable name from memory is where small mistakes hide: a stray capital, a missing word, a name that moved to another environment. Autocomplete removes the guesswork, and the hover preview tells you what will actually go on the wire.

Try it in API Spector

Free and open source. No account needed to use the app.

Keep reading