Extract APIs from Codebase

The maeris scan api command statically analyzes your codebase to discover every HTTP call your application makes. It extracts endpoints, methods, headers, request bodies, and environment variables — then automatically organizes them into a Maeris collection ready for testing.

Running the API Scan

From your project root, run:

maeris scan api

For a faster scan that skips deep dependency traversal:

maeris scan api --quick

The --quick flag limits scanning to your source files only (e.g., src/, pages/, app/) and skips node_modules and build artifacts. Recommended for large monorepos.

What Gets Detected

The scanner detects HTTP calls made using any of the following libraries:

  • JavaScript/TypeScript: fetch(), axios, got, superagent, ky
  • Python: requests, httpx, aiohttp, urllib
  • Next.js: getServerSideProps, getStaticProps, Route Handlers (app/api/)
  • React Query / SWR: Detected via useQuery, useMutation, useSWR hook calls

What Gets Extracted

For each discovered API call, Maeris extracts:

Method & URL

The HTTP method (GET, POST, PUT, PATCH, DELETE) and the full URL pattern. Dynamic path segments like /users/123 are normalized to /users/{id}.

Headers

Static headers (Content-Type, Accept) and dynamic headers (Authorization with Bearer tokens) are captured. Token values are replaced with environment variable placeholders like {{auth_token}}.

Request Body & Query Params

JSON bodies, form data, and query parameter structures are extracted from your source code and stored as editable fields in the collection.

Environment Variables

References to process.env.API_URL, import.meta.env.VITE_API_BASE, or Python os.environ calls are detected and automatically added to the generated Maeris environment.

Auto-Created Collection and Environment

After the scan, Maeris automatically:

  1. Creates a new collection named after your project (e.g., my-app APIs)
  2. Organizes APIs into sub-collections by domain (e.g., Authentication, Users, Products)
  3. Creates a Maeris environment with all detected variable names (values are left blank for you to fill in)
  4. Links the environment to the new collection automatically

Pushing Scan Results to Portal

After the scan creates your collection locally, sync it to the Maeris Portal:

maeris scan push

This uploads the collection, all APIs, and the auto-generated environment to your Maeris application on the portal where your team can view, edit, and run them.

Example Scan Output

API Scan complete: 47 endpoints discovered

Authentication (6)
  POST /api/auth/login
  POST /api/auth/register
  POST /api/auth/logout
  GET  /api/auth/me
  POST /api/auth/reset-password
  POST /api/auth/verify-email

Users (8)
  GET  /api/users
  GET  /api/users/{id}
  POST /api/users
  ...

Environment variables detected: API_BASE_URL, AUTH_TOKEN, STRIPE_KEY

Collection "my-app APIs" created with 47 APIs.
Environment "my-app env" created with 3 variables.

Next Steps

After scanning, organize and manage your new collection. See the Collections & Organization guide for how to arrange APIs, add sub-collections, and work with the Maeris collection model.