Lens · Capability

Lens API

The Lens API provides programmatic access to the full corpus of Lens scholarly works and patents using a REST interface. The API supports rich Elasticsearch-style query DSL for searching scholarly publications and global patent records, with cursor-based pagination, sorting, and field projection. Authentication is via a bearer token issued from the Lens user profile.

Run with Naftiko LensAPI

What You Can Do

GET
Get scholarly search — Search scholarly works (GET)
/scholarly/search
POST
Post scholarly search — Search scholarly works (POST)
/scholarly/search
GET
Get scholarly lens id — Get a scholarly work by Lens ID
/scholarly/{lens_id}
GET
Get patent search — Search patents (GET)
/patent/search
POST
Post patent search — Search patents (POST)
/patent/search
GET
Get patent lens id — Get a patent by Lens ID
/patent/{lens_id}

MCP Tools

get-scholarly-search

Search scholarly works (GET)

read-only idempotent
post-scholarly-search

Search scholarly works (POST)

get-scholarly-lens-id

Get a scholarly work by Lens ID

read-only idempotent
get-patent-search

Search patents (GET)

read-only idempotent
post-patent-search

Search patents (POST)

get-patent-lens-id

Get a patent by Lens ID

read-only idempotent

Capability Spec

lens-capability.yaml Raw ↑
naftiko: 1.0.0-alpha2
info:
  label: Lens API
  description: The Lens API provides programmatic access to the full corpus of Lens scholarly works and patents using a REST
    interface. The API supports rich Elasticsearch-style query DSL for searching scholarly publications and global patent
    records, with cursor-based pagination, sorting, and field projection. Authentication is via a bearer token issued from
    the Lens user profile.
  tags:
  - Lens
  - API
  created: '2026-05-06'
  modified: '2026-05-06'
capability:
  consumes:
  - type: http
    namespace: lens
    baseUri: https://api.lens.org
    description: Lens API HTTP API.
    authentication:
      type: bearer
      token: '{{LENS_TOKEN}}'
    resources:
    - name: scholarly-search
      path: /scholarly/search
      operations:
      - name: get-scholarly-search
        method: GET
        description: Search scholarly works (GET)
        inputParameters:
        - name: query
          in: query
          type: string
          required: true
          description: Lucene-style query string (e.g. "title:graphene AND year:2024").
        - name: size
          in: query
          type: integer
          description: Number of records per page (max 1000 for Patents/Scholarly subject to plan).
        - name: from
          in: query
          type: integer
          description: Offset for offset/size pagination. Cannot exceed 10000 in total.
        - name: sort
          in: query
          type: string
          description: Comma-separated sort directives (e.g. "desc(patent_citation_count)").
        - name: include
          in: query
          type: string
          description: Comma-separated list of fields to include in the response.
        - name: exclude
          in: query
          type: string
          description: Comma-separated list of fields to exclude from the response.
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
      - name: post-scholarly-search
        method: POST
        description: Search scholarly works (POST)
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
    - name: scholarly-lens-id
      path: /scholarly/{lens_id}
      operations:
      - name: get-scholarly-lens-id
        method: GET
        description: Get a scholarly work by Lens ID
        inputParameters:
        - name: lens_id
          in: path
          type: string
          required: true
          description: Unique Lens identifier for the scholarly work.
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
    - name: patent-search
      path: /patent/search
      operations:
      - name: get-patent-search
        method: GET
        description: Search patents (GET)
        inputParameters:
        - name: query
          in: query
          type: string
          required: true
          description: Lucene-style query string.
        - name: size
          in: query
          type: integer
        - name: from
          in: query
          type: integer
        - name: sort
          in: query
          type: string
        - name: include
          in: query
          type: string
        - name: exclude
          in: query
          type: string
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
      - name: post-patent-search
        method: POST
        description: Search patents (POST)
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
    - name: patent-lens-id
      path: /patent/{lens_id}
      operations:
      - name: get-patent-lens-id
        method: GET
        description: Get a patent by Lens ID
        inputParameters:
        - name: lens_id
          in: path
          type: string
          required: true
          description: Unique Lens identifier for the patent record.
        outputRawFormat: json
        outputParameters:
        - name: result
          type: object
          value: $.
  exposes:
  - type: rest
    port: 8080
    namespace: lens-rest
    description: REST adapter for Lens API.
    resources:
    - path: /scholarly/search
      name: get-scholarly-search
      operations:
      - method: GET
        name: get-scholarly-search
        description: Search scholarly works (GET)
        call: lens.get-scholarly-search
        outputParameters:
        - type: object
          mapping: $.
    - path: /scholarly/search
      name: post-scholarly-search
      operations:
      - method: POST
        name: post-scholarly-search
        description: Search scholarly works (POST)
        call: lens.post-scholarly-search
        outputParameters:
        - type: object
          mapping: $.
    - path: /scholarly/{lens_id}
      name: get-scholarly-lens-id
      operations:
      - method: GET
        name: get-scholarly-lens-id
        description: Get a scholarly work by Lens ID
        call: lens.get-scholarly-lens-id
        with:
          lens_id: rest.lens_id
        outputParameters:
        - type: object
          mapping: $.
    - path: /patent/search
      name: get-patent-search
      operations:
      - method: GET
        name: get-patent-search
        description: Search patents (GET)
        call: lens.get-patent-search
        outputParameters:
        - type: object
          mapping: $.
    - path: /patent/search
      name: post-patent-search
      operations:
      - method: POST
        name: post-patent-search
        description: Search patents (POST)
        call: lens.post-patent-search
        outputParameters:
        - type: object
          mapping: $.
    - path: /patent/{lens_id}
      name: get-patent-lens-id
      operations:
      - method: GET
        name: get-patent-lens-id
        description: Get a patent by Lens ID
        call: lens.get-patent-lens-id
        with:
          lens_id: rest.lens_id
        outputParameters:
        - type: object
          mapping: $.
  - type: mcp
    port: 9090
    namespace: lens-mcp
    transport: http
    description: MCP adapter for Lens API for AI agent use.
    tools:
    - name: get-scholarly-search
      description: Search scholarly works (GET)
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: lens.get-scholarly-search
      with:
        query: tools.query
        size: tools.size
        from: tools.from
        sort: tools.sort
        include: tools.include
        exclude: tools.exclude
      inputParameters:
      - name: query
        type: string
        description: Lucene-style query string (e.g. "title:graphene AND year:2024").
        required: true
      - name: size
        type: integer
        description: Number of records per page (max 1000 for Patents/Scholarly subject to plan).
      - name: from
        type: integer
        description: Offset for offset/size pagination. Cannot exceed 10000 in total.
      - name: sort
        type: string
        description: Comma-separated sort directives (e.g. "desc(patent_citation_count)").
      - name: include
        type: string
        description: Comma-separated list of fields to include in the response.
      - name: exclude
        type: string
        description: Comma-separated list of fields to exclude from the response.
      outputParameters:
      - type: object
        mapping: $.
    - name: post-scholarly-search
      description: Search scholarly works (POST)
      hints:
        readOnly: false
        destructive: false
        idempotent: false
      call: lens.post-scholarly-search
      outputParameters:
      - type: object
        mapping: $.
    - name: get-scholarly-lens-id
      description: Get a scholarly work by Lens ID
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: lens.get-scholarly-lens-id
      with:
        lens_id: tools.lens_id
      inputParameters:
      - name: lens_id
        type: string
        description: Unique Lens identifier for the scholarly work.
        required: true
      outputParameters:
      - type: object
        mapping: $.
    - name: get-patent-search
      description: Search patents (GET)
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: lens.get-patent-search
      with:
        query: tools.query
        size: tools.size
        from: tools.from
        sort: tools.sort
        include: tools.include
        exclude: tools.exclude
      inputParameters:
      - name: query
        type: string
        description: Lucene-style query string.
        required: true
      - name: size
        type: integer
        description: size
      - name: from
        type: integer
        description: from
      - name: sort
        type: string
        description: sort
      - name: include
        type: string
        description: include
      - name: exclude
        type: string
        description: exclude
      outputParameters:
      - type: object
        mapping: $.
    - name: post-patent-search
      description: Search patents (POST)
      hints:
        readOnly: false
        destructive: false
        idempotent: false
      call: lens.post-patent-search
      outputParameters:
      - type: object
        mapping: $.
    - name: get-patent-lens-id
      description: Get a patent by Lens ID
      hints:
        readOnly: true
        destructive: false
        idempotent: true
      call: lens.get-patent-lens-id
      with:
        lens_id: tools.lens_id
      inputParameters:
      - name: lens_id
        type: string
        description: Unique Lens identifier for the patent record.
        required: true
      outputParameters:
      - type: object
        mapping: $.
binds:
- namespace: env
  keys:
    LENS_TOKEN: LENS_TOKEN