---
openapi: 3.0.3
info:
  title: Vessel API
  description: The Fdir Vessel REST API
  termsOfService: https://data.norge.no/nlod/no/
  contact:
    name: Fdir Dev Team
    email: tfr@fiskeridir.no
  license:
    name: FDIR data usage license
    url: https://www.fiskeridir.no/Tall-og-analyse/Lisens-for-bruk-av-Fiskeridirektoratets-data
  version: 1.0.0
servers:
- url: https://api.fiskeridir.no
tags:
- name: Vessels
paths:
  /vessel-api/api/v1/vessels:
    get:
      tags:
      - Vessels
      summary: List active vessels
      parameters:
      - name: length_gte
        in: query
        description: Filter by vessel length greater than or equal to
        schema:
          format: double
          minimum: 0
          type: number
      - name: length_lte
        in: query
        description: Filter by vessel length less than or equal to
        schema:
          format: double
          type: number
      - name: municipality_code
        in: query
        description: Filter by vessel municipality code
        schema:
          type: string
      - name: name
        in: query
        description: Filter by vessel name
        schema:
          type: string
      - name: page
        in: query
        description: Page number of the results to fetch
        schema:
          format: int32
          minimum: 1
          type: integer
      - name: per_page
        in: query
        description: Number of vessels per page (max 200)
        schema:
          format: int32
          default: "30"
          maximum: 200
          minimum: 1
          type: integer
      - name: query
        in: query
        description: Search across multiple fields
        schema:
          type: string
      - name: radio_call_sign
        in: query
        description: Filter by vessel call sign
        schema:
          type: string
      - name: registration_mark
        in: query
        description: Filter by vessel registration mark
        schema:
          type: string
      - name: sort_asc
        in: query
        schema:
          default: false
          type: boolean
      - name: sort_by
        in: query
        schema:
          allOf:
          - $ref: '#/components/schemas/VesselSortField'
          - default: ID
      responses:
        "200":
          description: OK
          headers:
            x-totalcount:
              description: Total count of vessels
              style: simple
              schema:
                type: number
            link:
              description: "Get the URL for the first, prev, next and last page of\
                \ vessels"
              style: simple
              schema:
                type: string
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Vessel'
  /vessel-api/api/v1/vessels/{id}:
    get:
      tags:
      - Vessels
      summary: Returns a specific vessel
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Vessel'
components:
  schemas:
    EntityType:
      enum:
      - COMPANY
      - PERSON
      type: string
    Owner:
      description: ' This is an object representing a Vessel Owner.'
      type: object
      properties:
        id:
          type: string
        entityType:
          $ref: '#/components/schemas/EntityType'
        name:
          type: string
        postalCode:
          type: string
        city:
          type: string
    Vessel:
      description: ' This is an object representing a Vessel.'
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        registrationMark:
          type: string
        radioCallSign:
          type: string
        imoNumber:
          type: string
        municipalityCode:
          type: string
        width:
          type: number
        length:
          type: number
        enginePower:
          format: int32
          type: integer
        owners:
          type: array
          items:
            $ref: '#/components/schemas/Owner'
    VesselSearchCriteria:
      type: object
      properties:
        query:
          type: string
        registrationMark:
          type: string
        radioCallSign:
          type: string
        name:
          type: string
        municipalityCode:
          type: string
        lengthGte:
          format: double
          minimum: 0
          type: number
        lengthLte:
          format: double
          type: number
        sortBy:
          $ref: '#/components/schemas/VesselSortField'
        sortAsc:
          type: boolean
    VesselSortField:
      enum:
      - ID
      - NAME
      - REGISTRATIONMARK
      - RADIOCALLSIGN
      type: string
