# Search code by keyword and FIBO concept with ForwardLane's API

ForwardLane's Code Knowledge Graph finds functions and classes by the words they use, and its FIBO Ontology Code Mapping finds the functions that implement a financial concept such as Account. Both work across the private financial-services repositories ForwardLane analysed. A keyword search costs $0.05 and a concept lookup costs $0.05. To call either one, send a `GET` to `https://agents.forwardlane.com/zcj/2pgwk1javupl/api/search/hybrid` with `mode=bm25` or to `https://agents.forwardlane.com/zcj/2pgwk1javupl/api/skills/by-ontology`, then pay the 402 price quote and retry.

## At a glance

- **Keyword search:** `GET https://agents.forwardlane.com/zcj/2pgwk1javupl/api/search/hybrid?q=<words>&mode=bm25`, $0.05
- **Concept lookup:** `GET https://agents.forwardlane.com/zcj/2pgwk1javupl/api/skills/by-ontology?concept=<name or URI>`, $0.05
- **Body:** none. Every call is a `GET` with query parameters, such as `q`, `mode`, `top_k`, `node_type` and `repo` for a search, or `concept` and `limit` for a lookup.
- **Graph listings:** functions, classes, data models, API endpoints and a repository's neighbours at $0.02 each. Full graph export at $0.05.
- **Payment:** a 402 is the price quote, which you pay and retry. No account or API key is needed.
- **Response:** JSON. Each search match carries `name`, `repo`, `file_path`, `docstring`, `complexity`, `score` and `ontology_matches`.
- **Limits:** `q` up to 512 characters. `top_k` from 1 to 100, default 20. A concept lookup's `limit` runs from 1 to 100, default 20.
- **Full purchase flow:** [the buyer skill](https://agents.forwardlane.com/zcj/2pgwk1javupl/SKILL.md)

## What the graph holds

The graph has these node types: Function, Class, SourceFile, DataModel (ORM model classes), ModelField, APIEndpoint (endpoints extracted from URL patterns), TestCase, SecurityPattern, ConfigFile and Contributor. `GET https://agents.forwardlane.com/zcj/2pgwk1javupl/api/deep-stats` ($0) returns the count of each type. The example response counted about 50,600 functions, 12,700 classes and 13,400 source files, with the other types in the hundreds or low thousands.

Typed edges join the nodes: `CONTAINS`, `CALLS`, `INHERITS`, `IMPORTS`, `DEPENDS_ON` and `CONTRIBUTED_TO`. The call graph alone holds about 550,000 `CALLS` edges, and class inheritance about 46,000 `INHERITS` edges.

## Search functions and classes by keyword

1. Send the search. Set `mode=bm25`, which ranks matches by lexical match on the words in `q`:

   ```bash
   curl -i "https://agents.forwardlane.com/zcj/2pgwk1javupl/api/search/hybrid?q=portfolio&mode=bm25&top_k=3"
   ```

   The storefront answers `402` with a quote for $0.05. Nothing is charged at this point.

2. Pay the quote with an x402 or MPP client and resend the same request with the proof attached. [The buyer skill](https://agents.forwardlane.com/zcj/2pgwk1javupl/SKILL.md) has the steps.

3. Read the matches. The example search returned three matches in 0.2 seconds. The response has this shape:

   ```json
   {
     "query": "<q>", "mode": "<mode>", "node_type": "<node_type>", "count": <number>,
     "results": [{
       "name": "<function_name>", "repo": "<repo>", "file_path": "<file_path>",
       "args": "<args>", "decorators": "<decorators>", "docstring": "<docstring>",
       "line_count": <number>, "complexity": <number>, "is_async": <boolean>, "lineno": <number>,
       "_labels": ["<label>"], "_score": <number>, "score": <number>,
       "ontology_matches": [{"uri": "<concept_uri>", "name": "<concept_name>", "confidence": <number>}]
     }],
     "filters": {}
   }
   ```

   Each match carries `ontology_matches`, the ontology concepts mapped to it, each with its `uri`, `name` and `confidence`.

Narrow a search with these parameters:

| To get | Add |
| --- | --- |
| Classes instead of functions | `node_type=Class` |
| Matches in one repository | `repo=<repo>` |
| Functions with linked tests | `has_tests=true` |
| Functions in one domain | `domain=<domain>` |
| Functions mapped to a concept | `ontology_concept_uri=<concept_uri>` |
| Only stronger concept mappings | `confidence_min=<0 to 1>` |

The `domain`, `has_tests`, `ontology_concept_uri` and `confidence_min` filters apply to Function results only.

## Find code that implements a financial concept

1. Send the concept by name or by URI:

   ```bash
   curl -i "https://agents.forwardlane.com/zcj/2pgwk1javupl/api/skills/by-ontology?concept=Account&limit=3"
   ```

   The 402 quotes $0.05. Pay it and retry.

2. Read the functions. The example lookup for `Account` returned three functions in 0.2 seconds, and the response resolved the name to its URI in `concept.uri`. The functions come back ordered by mapping confidence, in this shape:

   ```json
   {
     "concept": {"uri": "<concept_uri>", "name": "<concept_name>"},
     "limit": <number>, "count": <number>,
     "items": [{"name": "<function_name>", "repo": "<repo>", "file_path": "<file_path>",
                "docstring": "<docstring>", "domain": null, "complexity": <number>,
                "mapped_confidence": <number>}]
   }
   ```

3. To run a keyword search inside that concept, pass the value of `concept.uri` as `ontology_concept_uri`, URL-encoded.

The mapping holds 82,053 function-to-concept triples across 17 ontologies, including FIBO, FIBO-Wealth, GLEIF-LEI, CWE and OWASP.

## List and export the graph

| To get | Request | Price |
| --- | --- | --- |
| Functions by name, complexity or repository | `GET /api/functions?name=<substring>&min_complexity=<n>&repo=<repo>` | $0.02 |
| Classes by name or repository | `GET /api/classes?name=<substring>&repo=<repo>` | $0.02 |
| Data models | `GET /api/models?repo=<repo>` | $0.02 |
| API endpoints | `GET /api/endpoints?repo=<repo>` | $0.02 |
| A repository's immediate neighbours | `GET /api/graph/neighbors/{name}` | $0.02 |
| Every node and edge with their properties | `GET /api/graph` | $0.05 |

Listings take `limit` from 1 to 1000, default 100. Take repository names from the `repo` field of a search match.

## Boundaries

- The data describes the repositories ForwardLane analysed. No endpoint takes your own code. Every endpoint is a synchronous read that returns JSON.
- A match gives a function's name, arguments, docstring and location.
- An unpaid 402 charges nothing, so you can stop at the quote.
- A card pays a single call only at $0.50 or more. To pay these calls by card, buy Credits and draw each call from the balance; [the buyer skill](https://agents.forwardlane.com/zcj/2pgwk1javupl/SKILL.md) covers buying them.

## Errors

| Response | Meaning | Action |
| --- | --- | --- |
| `402` | The price quote | Pay and retry the same request, or stop |
| `404` on `/api/skills/by-ontology` | The concept is not found | Try the concept's URI or another name |
| `404` on `/api/graph/neighbors/{name}` | The repository is unknown | Use a `repo` value from a search match |
| `422` | A parameter failed validation, such as `top_k` out of range or `q` missing | Fix the field named in `detail` |
| `settlement_failed` | The payment did not settle | Fix the wallet and send a fresh request |
| `usage_exhausted` | Prepaid credit ran out | Top up with `POST https://agents.forwardlane.com/zcj/2pgwk1javupl/extend` |

## Frequently asked questions

### Can the code search API return classes as well as functions?

Yes. Set `node_type=Class`. The `domain`, `has_tests`, `ontology_concept_uri` and `confidence_min` filters apply only when you search functions.

### Which financial ontologies does the FIBO code mapping cover?

It covers 17 ontologies, including FIBO, FIBO-Wealth, GLEIF-LEI, CWE and OWASP. Together they hold 82,053 function-to-concept triples. A concept can be sent by name or by URI.

### Does the API search my own repositories?

No. It returns data about the repositories ForwardLane analysed. There is no endpoint for submitting code.

### How much does a code search cost?

A keyword search is $0.05 and a concept lookup is $0.05. The 402 states the exact price before each payment.

### Do I need an account or an API key?

No. Each call is paid on its own over x402 or MPP. Only prepaid Credits need the bearer credential the storefront issues.

## Keep reading

- [Buyer skill](https://agents.forwardlane.com/zcj/2pgwk1javupl/SKILL.md): the full purchase flow
- [How to pay](https://agents.forwardlane.com/zcj/2pgwk1javupl/payment.md): rails, Credits and top-ups
- [Code Knowledge Graph API reference](https://agents.forwardlane.com/zcj/2pgwk1javupl/services/code-knowledge-graph/openapi.json)
- [Error reference](https://agents.forwardlane.com/zcj/2pgwk1javupl/errors.md)

---

Updated 2026-10-26. All ForwardLane guides: https://agents.forwardlane.com/guides.md. Storefront: https://agents.forwardlane.com/zcj/2pgwk1javupl/llms.txt.
