Importing a Postman collection¶
How-to guideThe steps for one task.
If your API lives in Postman, the console turns the collection into an API with one operation per request. You review and edit everything before anything is created.
- In Postman, open the collection's ⋯ menu › Export › Collection v2.1 (v2.0 works too).
- Admin → Import & export → Import an API → Postman collection: choose the file or paste it. Collections up to 3 MB are imported.
- The preview proposes the API, its backend, its operations and policies. Edit names, the base path, paths and the backend; remove operations you do not want exposed; untick a suggested policy to leave it out.
- Create API and N operations. It is all or nothing: everything is created in the draft, or nothing is and every problem is listed. Nothing serves traffic until you deploy.
Importing creates objects for the whole draft, so it is for administrators, as the OpenAPI import is.
What becomes what¶
| In the collection | In Apinx |
|---|---|
| The collection's name | The API's name: Acme Mobile API becomes acme-mobile-api; a number is added if the name is taken |
| The first paragraph of its description | The API's description |
{{baseUrl}}, the host most requests use |
The backend: a new upstream with that address, or the existing upstream that already reaches it |
The path in {{baseUrl}} (https://api.acme.example/v1) |
The API's base path (/v1): callers keep it, and the backend still receives it |
| Each request | One operation: its method and path |
| Folders | Name prefixes: the request Get user in the folder Users becomes users-get-user; the preview shows the folder |
:id, {{id}} or {id} in a path |
The path parameter {id}, available to policies as ${path.id} |
| The collection's auth, a folder's or a request's | Suggested policies (below) |
| Query parameters, headers, bodies, scripts, tests, saved responses | Not imported |
A parameter covers a whole path segment, so /files/:name.json becomes /files/{name}. The
gateway names a position in a path once for every operation under it: when one request uses
/users/:id and another /users/:userId, both become /users/{id}. A {{variable}} in a path
is a parameter even when the collection gives it a value. The preview's notes list every such
change.
Auth becomes suggested policies¶
| Postman auth | Suggested policy | After creating |
|---|---|---|
| API Key, in a header or the query | api-key with the same header or parameter name |
On. Issue keys to your callers under Consumers (Consumers and API keys) |
OAuth 2.0 client credentials whose token URL is this gateway's /oauth2/token, or has none |
oauth2 |
On: issue a client secret to the application under Consumers (Apinx-issued tokens) |
| Bearer Token, other OAuth 2.0, JWT Bearer | jwt |
Switched off: enter your identity provider's issuer (Authenticating callers with JWT), then switch it on. Until then your backend keeps checking tokens itself |
| Basic Auth | basic |
Switched off: add the users and their passwords, then switch it on |
| No Auth on a request or a folder | The operation switches the API's policy off: sign-in, sign-up, health | |
| Digest, OAuth 1.0, Hawk, AWS Signature, NTLM, Akamai EdgeGrid, ASAP | None: the backend keeps checking it |
The collection's auth goes on the API; without one, the auth every request shares does. A request or folder with an auth of its own gets it on its operation. Unticking a suggestion in the preview also drops the operations' exceptions to it.
Secrets are never imported: no API key, token, password, client secret or credentials written into a URL, and no variable value but the backend's address. The collection itself is not kept with the API.
The gateway takes the caller's API key off the request before calling the backend. If your backend checks a key of its own, have the gateway send it: Authenticating to a backend.
The backend address¶
- localhost: in Postman,
http://localhost:3000is your own computer. The gateway calls the backend from its own host, so enter an address it can reach; in Apinx Cloud that is a public address. The preview warns about it. {{baseUrl}}without a value: it lives in a Postman environment, not in the collection. Enter the address in the preview, or choose an existing upstream.
What is not imported¶
The preview lists each request it left out and why; none of them stops the API being created.
- Requests without a URL, and items that are neither a request nor a folder.
- WebSocket (
ws://,wss://) and gRPC requests: add those operations by hand (gRPC services). - Methods the gateway does not route, such as WebDAV's
PROPFINDorLINK. - Requests to another host than the backend, such as a token service or a reports server: import those as an API of their own.
- A second request with the same method and path, such as Login and Login as admin: one operation serves both.
- Folders nested deeper than 32 levels.
Problems you fix in the preview¶
Two operations on the same method and path, a name that is not lowercase letters, digits and hyphens, or a path the gateway cannot match are marked on the operation as you type, and Create waits until they are fixed. The gateway checks the same again when creating and refuses the whole import while anything is left.
Files that are refused¶
| The file | What to do |
|---|---|
Over 3 MB (APX-GW-0011) |
Delete the saved example responses, which take most of the space and are not imported anyway, or export one folder at a time and import each as its own API |
A Postman Collection v1 (APX-GW-0010) |
Open it in Postman and export it again as Collection v2.1 |
A Postman environment or data dump (APX-GW-0010) |
Export the collection itself |
An OpenAPI document (APX-GW-0010) |
Use the OpenAPI import: Importing an OpenAPI document |
Not JSON, or no requests (APX-GW-0009) |
Export the collection again from Postman |
From the Admin API¶
The console's two steps are two operations: POST /api/v1/import/postman/preview with the
collection returns the proposal, and POST /api/v1/import/postman creates it, as edited
({"proposal": …}) or as previewed ({"document": …}):
jq -n --rawfile doc acme.postman_collection.json '{document: $doc}' |
curl -s -X POST localhost:9000/api/v1/import/postman/preview \
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' -d @-
The other way round, every API and product exports a Postman collection for its callers: the Postman button on its page.