> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loci.ng/llms.txt
> Use this file to discover all available pages before exploring further.

# The frame at a location

> Resolves a longitude and latitude to the frame that contains it: the cell's id, its shape, and its bounding box.

This is the first call most integrations make. The id it returns is what the other three calls take. A device's own position, a geocoded address, a tapped point on a map: any of them becomes a frame id here.

`lng` is accepted as a spelling of `lon`. The answer is cacheable for ten minutes; the grid only changes when it is reloaded.

Needs the `frame.read` capability, which every scope preset grants.



## OpenAPI

````yaml /api-reference/openapi.json get /v1/frames/at
openapi: 3.1.0
info:
  title: LOCI API
  version: 1.0.0
  summary: >-
    The Milsat spatial index over HTTP: find the frame at a location, the frames
    around it, what is recorded on them, and a worded answer about them.
  description: >-
    Four calls, all under `/v1/frames`, all read-only, all with an API key.


    Nigeria is covered by a grid of **frames**: cells roughly a kilometre
    across, each with a stable numeric id. Every dataset on LOCI falls within
    frames, so a frame id is the key to everything known about a place. The API
    lets your code resolve a location to its frame, list the frames around a
    point, read what the datasets your organisation owns or licenses record on
    those frames, and ask a question about them in plain language.


    Every response is wrapped in an envelope: a success carries `data`, a
    failure carries `error` with a machine-readable `code` and a human
    `message`. Branch on the code; the message may be reworded.


    Send the key as `Authorization: Bearer loci_sk_…`. A key acts for one
    organisation, is read-only, and expires.
servers:
  - url: https://api.staging.loci.ng
    description: The LOCI API, which the app at loci.ng also uses.
  - url: http://localhost:8088
    description: A local development stack, which the examples here were captured against.
security:
  - apiKey: []
tags:
  - name: Frames
    description: The spatial index and what is recorded on it.
paths:
  /v1/frames/at:
    get:
      tags:
        - Frames
      summary: The frame at a location
      description: >-
        Resolves a longitude and latitude to the frame that contains it: the
        cell's id, its shape, and its bounding box.


        This is the first call most integrations make. The id it returns is what
        the other three calls take. A device's own position, a geocoded address,
        a tapped point on a map: any of them becomes a frame id here.


        `lng` is accepted as a spelling of `lon`. The answer is cacheable for
        ten minutes; the grid only changes when it is reloaded.


        Needs the `frame.read` capability, which every scope preset grants.
      operationId: frameAt
      parameters:
        - name: lat
          in: query
          required: true
          description: Latitude in degrees, −90 to 90.
          schema:
            type: number
          example: 9.0579
        - name: lon
          in: query
          required: true
          description: Longitude in degrees, −180 to 180. `lng` is accepted too.
          schema:
            type: number
          example: 7.4951
      responses:
        '200':
          description: The frame containing the point.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Frame'
                required:
                  - data
              example:
                data:
                  id: '2163551'
                  geometry:
                    type: Polygon
                    coordinates:
                      - - - 7.5003
                          - 9.05143
                        - - 7.49131
                          - 9.05143
                        - - 7.49129
                          - 9.05145
                        - - 7.48751
                          - 9.05811
                        - - 7.48753
                          - 9.06201
                        - - 7.5003
                          - 9.06201
                        - - 7.5003
                          - 9.05143
                  bbox:
                    - 7.48751
                    - 9.05143
                    - 7.5003
                    - 9.06201
        '400':
          description: >-
            `lat` or `lon` is missing, not a number, or out of range. Code
            `invalid_point`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_point
                  message: lon and lat are required, in degrees
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/InsufficientScope'
        '404':
          description: The point lies outside the grid. Code `not_found`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: not_found
                  message: no frame contains that point
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/Internal'
components:
  schemas:
    Frame:
      type: object
      description: A cell of the spatial index.
      properties:
        id:
          type: string
          description: The frame's stable id, a numeric string.
          example: '2163551'
        geometry:
          $ref: '#/components/schemas/Geometry'
        bbox:
          $ref: '#/components/schemas/BBox'
      required:
        - id
        - geometry
        - bbox
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Stable and machine-readable. Branch on it.
            message:
              type: string
              description: For people. May be reworded.
          required:
            - code
            - message
      required:
        - error
    Geometry:
      type: object
      description: A GeoJSON geometry.
      properties:
        type:
          type: string
          example: Polygon
        coordinates:
          description: Positions as `[lon, lat]`, nested as GeoJSON requires for the type.
      required:
        - type
        - coordinates
    BBox:
      type: array
      description: '`[minLon, minLat, maxLon, maxLat]` in degrees.'
      items:
        type: number
      minItems: 4
      maxItems: 4
  responses:
    Unauthorized:
      description: >-
        No credential (`unauthorized`), or a key that is unknown, expired or
        revoked (`invalid_key`). A bad key is not treated as anonymous: the
        `loci_sk_` prefix proves a key was meant.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            none:
              value:
                error:
                  code: unauthorized
                  message: sign in, or send an API key
            invalid:
              value:
                error:
                  code: invalid_key
                  message: that API key is not valid, has expired, or was revoked
    InsufficientScope:
      description: >-
        The key does not carry `frame.read`. Every preset grants it, so this
        only arises on a key minted with an explicit capability list.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: insufficient_scope
              message: this API key does not carry the frame.read scope
    RateLimited:
      description: >-
        A budget is spent. `Retry-After` says how many seconds until the next
        request will pass.
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds to wait.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: rate_limited
              message: too many requests — retry in 5s
    Internal:
      description: >-
        Something failed on the server. The message is deliberately vague; retry
        once.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: internal
              message: could not look up the frame
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: loci_sk_…
      description: >-
        An API key minted in the Developers tab of the LOCI app, sent as
        `Authorization: Bearer loci_sk_…`. Acts for one organisation, is
        read-only, and expires.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.