# Make your first data request (https://guides.dataportal.gov.lt/docs/api/guides/overview)



Use the State Data Agency dataset [**Resident population at the beginning of the year | Administrative territory | Age (5 year groups) | Sex**](https://dataportal.gov.lt/en/datasets/sd001920) to practise finding a record and reading its rows. The table gives the population at the start of each year by municipality, five-year age group and sex.

<ParamTable
  columns="[&#x22;&#x22;, &#x22;Id&#x22;, &#x22;What it is&#x22;]"
  names="text"
  lang="en"
  params="[
  { name: &#x22;Dataset&#x22;, type: &#x22;sd001920&#x22;, description: &#x22;Its id in the catalogue.&#x22; },
  { name: &#x22;Organization&#x22;, type: &#x22;188600177&#x22;, description: &#x22;State Data Agency — the company code that holds its tables.&#x22; },
  { name: &#x22;Tables&#x22;, type: &#x22;S3R167_M3010203_en / _lt&#x22;, description: &#x22;The same data in English and in Lithuanian.&#x22; },
]"
/>

<Callout title="No sign-in">
  Send the requests to `https://api.dataportal.gov.lt`. No key is required. Searches and row queries use `POST` with a JSON body to read data.
</Callout>

## Three calls [#three-calls]

<Steps>
  <Step>
    ### Find the dataset [#find-the-dataset]

    Enter your search text in `q` and choose its language with `lang` (Lithuanian by default). Use `limit` to set the number of results per page.

    <MethodPath method="POST" path="/v1/datasets" />

    ```bash
    curl -X POST 'https://api.dataportal.gov.lt/v1/datasets' \
      -H 'Content-Type: application/json' \
      -d '{"q":"resident population administrative territory 5 year groups","lang":"en","limit":3}'
    ```

    ```json
    {
      "data": [
        {
          "id": "sd001920",
          "collection": "datasets",
          "title": "Resident population at the beginning of the year | Administrative territory | Age (5 year groups) | Sex",
          "links": { "self": "https://api.dataportal.gov.lt/v1/datasets/sd001920" }
        }
        /* … 2 more … */
      ],
      "meta": { "page": 1, "limit": 3, "total": 193, "total_pages": 65, "has_next": true }
    }
    ```
  </Step>

  <Step>
    ### Read its metadata [#read-its-metadata]

    Follow the result’s `self` link. The `distribution` array lists the Lithuanian and English tables. In the distribution you choose, follow `schema` for the column descriptions or `query` for rows.

    <MethodPath method="GET" path="/v1/datasets/{id}" />

    ```bash
    curl 'https://api.dataportal.gov.lt/v1/datasets/sd001920?lang=en'
    ```

    ```json
    {
      "id": "sd001920",
      "title": "Resident population at the beginning of the year | Administrative territory | Age (5 year groups) | Sex",
      "distribution": [
        {
          "identifier": "sdr001920_en",
          "table_id": "S3R167_M3010203_en",
          "language": [{ "id": "eng", "label": "English" }],
          "links": {
            "schema": { "href": "https://api.dataportal.gov.lt/v1/datasets/sd001920/distributions/sdr001920_en/schema?lang=en", "method": "GET" },
            "query": { "href": "https://api.dataportal.gov.lt/v1/data/organizations/188600177/tables/S3R167_M3010203_en/query", "method": "POST" }
          }
        }
        /* … the Lithuanian table, S3R167_M3010203_lt … */
      ]
      /* … description, temporal_coverage, publisher, … */
    }
    ```

    The `schema` link gives the column titles and counts of recorded distinct values. See [Searching the catalogue](https://guides.dataportal.gov.lt/docs/api/guides/searching#column-values) to retrieve the values themselves.
  </Step>

  <Step>
    ### Query the rows [#query-the-rows]

    Send a `POST` request to the `query` URL. This example selects the figures for both sexes in Panevėžys city municipality, with the most recent year first.

    <MethodPath method="POST" path="/v1/data/organizations/{id}/tables/{table}/query" />

    ```bash
    curl -X POST 'https://api.dataportal.gov.lt/v1/data/organizations/188600177/tables/S3R167_M3010203_en/query' \
      -H 'Content-Type: application/json' \
      -d "{\"select\":\"time_period,age_5_year_groups,s3r167\",\"filter\":\"administrative_territory='Panevėžys c. mun.'&sex='Males and females'&age_5_year_groups='Total by age'\",\"sort\":\"-time_period\",\"limit\":3}"
    ```

    ```json
    {
      "data": [
        { "time_period": "2026", "age_5_year_groups": "Total by age", "s3r167": 84319.0 },
        { "time_period": "2025", "age_5_year_groups": "Total by age", "s3r167": 85802.0 },
        { "time_period": "2024", "age_5_year_groups": "Total by age", "s3r167": 86595.0 }
      ],
      "total": 31,
      "total_pages": 11,
      "current_page": 1
    }
    ```

    Read `s3r167` for the population count. For other ways to filter rows, see [Querying tables](https://guides.dataportal.gov.lt/docs/api/guides/querying).
  </Step>
</Steps>

## Try it live [#try-it-live]

Choose columns, filters, sort order and page size, then select **Run**. The documentation server forwards the request so the example works in your browser without CORS headers from the API.

<ApiExplorer
  lang="en"
  organization="188600177"
  table="S3R167_M3010203_en"
  defaultSelected="[&#x22;administrative_territory&#x22;, &#x22;age_5_year_groups&#x22;, &#x22;sex&#x22;, &#x22;time_period&#x22;, &#x22;s3r167&#x22;]"
  defaultLimit="5"
  defaultSort="-time_period"
  defaultFilterColumn="administrative_territory"
  defaultFilterValue="Panevėžys c. mun."
  columns="[
  { name: &#x22;row_id&#x22;, type: &#x22;string&#x22; },
  { name: &#x22;age_5_year_groups&#x22;, type: &#x22;string&#x22; },
  { name: &#x22;sex&#x22;, type: &#x22;string&#x22; },
  { name: &#x22;administrative_territory&#x22;, type: &#x22;string&#x22; },
  { name: &#x22;administrative_territory_code&#x22;, type: &#x22;string&#x22; },
  { name: &#x22;time_period&#x22;, type: &#x22;string&#x22; },
  { name: &#x22;s3r167&#x22;, type: &#x22;double&#x22; },
  { name: &#x22;unit_of_measurement&#x22;, type: &#x22;string&#x22; },
  { name: &#x22;conventional_symbol&#x22;, type: &#x22;string&#x22; },
]"
  sample="{
  data: [
    { age_5_year_groups: &#x22;45–49&#x22;, sex: &#x22;Females&#x22;, administrative_territory: &#x22;Panevėžys c. mun.&#x22;, time_period: &#x22;2026&#x22;, s3r167: 2581 },
    { age_5_year_groups: &#x22;0–4&#x22;, sex: &#x22;Males&#x22;, administrative_territory: &#x22;Panevėžys c. mun.&#x22;, time_period: &#x22;2026&#x22;, s3r167: 1283 },
  ],
  total: 1860,
  total_pages: 372,
  current_page: 1,
}"
/>

## What else you can do [#what-else-you-can-do]

<EndpointTable
  lang="en"
  endpoints="[
  { task: &#x22;Search everything at once&#x22;, note: &#x22;Free text across all four collections; each result names its collection.&#x22;, method: &#x22;POST&#x22;, path: &#x22;/v1/search&#x22;, href: &#x22;/docs/api/search/search-metadata&#x22;, link: &#x22;Reference →&#x22; },
  { task: &#x22;List the filters&#x22;, note: &#x22;A collection's filters, their types and its sort options.&#x22;, method: &#x22;GET&#x22;, path: &#x22;/v1/datasets/filters&#x22;, href: &#x22;/docs/api/guides/searching#filters&#x22;, link: &#x22;Filters →&#x22; },
  { task: &#x22;List a filter's values&#x22;, note: &#x22;The codes to put in a search's filters, with record counts.&#x22;, method: &#x22;GET&#x22;, path: &#x22;/v1/datasets/filters/{filter_id}/values&#x22;, href: &#x22;/docs/api/datasets/list-dataset-filter-values&#x22;, link: &#x22;Reference →&#x22; },
  { task: &#x22;List a column's values&#x22;, note: &#x22;The exact values for a table filter, such as all 74 territories.&#x22;, method: &#x22;GET&#x22;, path: &#x22;/v1/datasets/{id}/distributions/{distribution_id}/schema/{column_id}/enums&#x22;, href: &#x22;/docs/api/guides/searching#column-values&#x22;, link: &#x22;Column values →&#x22; },
  { task: &#x22;Browse an organization's tables&#x22;, note: &#x22;The names of every table an organization stores.&#x22;, method: &#x22;GET&#x22;, path: &#x22;/v1/data/organizations/{id}/tables&#x22;, href: &#x22;/docs/api/data/list-organization-tables&#x22;, link: &#x22;Reference →&#x22; },
  { task: &#x22;Download a table as a file&#x22;, note: &#x22;CSV, Excel, Parquet, JSON or NDJSON; the same body as a query.&#x22;, method: &#x22;POST&#x22;, path: &#x22;/v1/data/organizations/{id}/tables/{table}/export&#x22;, href: &#x22;/docs/api/guides/downloading&#x22;, link: &#x22;Downloading →&#x22; },
  { task: &#x22;Search classifications&#x22;, note: &#x22;Code lists and statistical classifications, such as EVRK.&#x22;, method: &#x22;POST&#x22;, path: &#x22;/v1/classifications&#x22;, href: &#x22;/docs/api/classifications/search-classifications&#x22;, link: &#x22;Reference →&#x22; },
  { task: &#x22;Search data reuses&#x22;, note: &#x22;Apps, visualizations and studies built on the portal's data.&#x22;, method: &#x22;POST&#x22;, path: &#x22;/v1/reuses&#x22;, href: &#x22;/docs/api/reuses/search-reuses&#x22;, link: &#x22;Reference →&#x22; },
  { task: &#x22;Search organizations&#x22;, note: &#x22;The publishing organizations and their company codes.&#x22;, method: &#x22;POST&#x22;, path: &#x22;/v1/organizations&#x22;, href: &#x22;/docs/api/organizations/search-organizations&#x22;, link: &#x22;Reference →&#x22; },
]"
/>

## Where next [#where-next]

<Cards>
  <Card title="How catalogue records relate to data" href="https://guides.dataportal.gov.lt/docs/api/guides/concepts" description="Identify records, distributions and tables, and choose the right schema for the task." />

  <Card title="Search the catalogue through the API" href="https://guides.dataportal.gov.lt/docs/api/guides/searching" description="Search metadata by text, combine filters and choose which fields to return." />

  <Card title="Query table rows" href="https://guides.dataportal.gov.lt/docs/api/guides/querying" description="Choose columns, build a row filter and retrieve sorted results one page at a time." />

  <Card title="Examples for common API tasks" href="https://guides.dataportal.gov.lt/docs/api/guides/recipes" description="Look up a dataset by code, find its latest period or export figures for a single municipality." />
</Cards>
