openapi: 3.0.0 info: title: AI-powered Species Identification API description: This API provides endpoints for image-based species identification, taxon information retrieval, and various utility functions related to species data management. version: 1.0.0 servers: - url: https://ai.artsdatabanken.no description: Production - url: https://ai.test.artsdatabanken.no description: Test components: securitySchemes: apiToken: type: http scheme: bearer description: > API token issued with POST /admin/tokens. Tokens that carry a secret must additionally sign each request, see the X-Artsorakel-Signature parameter on /identify. Tokens restricted to a set of origins are accepted only when the browser sends a matching Origin header. adminToken: type: http scheme: bearer description: The ADMIN_TOKEN configured on the server. Required by every /admin route. paths: /: get: summary: Service status description: > Returns an HTML page with the deployed commit, the branch and the time server.js was last modified. Used as the health check. tags: - Utility responses: '200': description: HTML page post: summary: Identify species from image description: Identifies species from uploaded images using AI. tags: - Identification requestBody: content: multipart/form-data: schema: type: object properties: image: type: array items: type: string format: binary description: Image file(s) to be analyzed application: type: string description: Name of the application making the request responses: '200': description: Successful response content: application/json: schema: type: object properties: predictions: type: array items: type: object properties: probability: type: number taxon: type: object properties: vernacularName: type: string name: type: string groupName: type: string scientificNameID: type: string infoUrl: type: string picture: type: string mapUrl: type: string description: Distribution map image, may be absent when there was no taxon id match. '500': description: Internal Server Error /taxon/image/{taxon}: get: summary: Get taxon image description: Retrieves the image URL for a given taxon. tags: - Taxon parameters: - in: path name: taxon required: true schema: type: string description: The taxon name responses: '200': description: Successful response content: text/plain: schema: type: string '500': description: Internal Server Error /taxon/images: get: summary: Get all taxon images description: Maps every scientific name that has a picture to the URL of its 128 px picture. tags: - Taxon responses: '200': description: Successful response content: application/json: schema: type: object additionalProperties: type: string '500': description: Internal Server Error /taxon/picture/{id}/{file}: get: summary: Get a taxon picture description: A square JPEG of a stored taxon picture, asked for as NxN.jpg (for example 128x128.jpg). Any size from 1 to 9999 can be asked for; the server sends the smallest stored size that is at least that big, or the largest stored size if none is. 64, 128 and 256 are always stored, 512 and 1024 when the crop was large enough, and the crop at its own full resolution (up to 8192 px) when that is larger than 1024. tags: - Taxon parameters: - in: path name: id required: true schema: type: string - in: path name: file required: true schema: type: string pattern: '^([1-9][0-9]{0,3})x\1\.jpg$' example: 128x128.jpg responses: '200': description: The picture content: image/jpeg: schema: type: string format: binary '404': description: Not found /taxon/images/view: get: summary: View taxon images description: Displays all taxon images in an HTML view. tags: - Taxon responses: '200': description: Successful response content: text/html: schema: type: string '500': description: Internal Server Error /admin/taxon/reload/name/{taxon}: post: summary: Reload taxon by name description: Reloads the cached information for a given taxon by name. tags: - Admin security: - adminToken: [] parameters: - in: path name: taxon required: true schema: type: string description: The taxon name responses: '200': description: Successful response content: application/json: schema: type: object '401': description: Unauthorized '403': description: Forbidden '500': description: Internal Server Error /admin/taxon/reload/id/{id}: post: summary: Reload taxon by ID description: Reloads the cached information for a given taxon by ID. tags: - Admin security: - adminToken: [] parameters: - in: path name: id required: true schema: type: string description: The taxon ID responses: '200': description: Successful response content: application/json: schema: type: object '401': description: Unauthorized '403': description: Forbidden '500': description: Internal Server Error /admin/taxon/cache: delete: summary: Clear taxon cache description: Clears all cached taxon data. tags: - Admin security: - adminToken: [] responses: '200': description: Successful response content: application/json: schema: type: object properties: message: type: string deleted: type: integer errors: type: integer totalFiles: type: integer '401': description: Unauthorized '403': description: Forbidden '500': description: Internal Server Error /admin/tokens: get: summary: List API tokens description: Lists all API tokens. tags: - Admin security: - adminToken: [] responses: '200': description: Successful response content: application/json: schema: type: object properties: count: type: integer tokens: type: array items: type: object properties: token: type: string name: type: string application: type: string enabled: type: boolean created: type: string '401': description: Unauthorized '403': description: Forbidden '500': description: Internal Server Error post: summary: Create API token description: Creates a new API token. tags: - Admin security: - adminToken: [] requestBody: content: application/json: schema: type: object required: - name - application properties: name: type: string application: type: string description: type: string responses: '201': description: Token created content: application/json: schema: type: object properties: message: type: string token: type: string name: type: string application: type: string enabled: type: boolean created: type: string warning: type: string '400': description: Bad request '401': description: Unauthorized '403': description: Forbidden '500': description: Internal Server Error /admin/tokens/reload: get: summary: Reload tokens description: Reloads tokens from the tokens file. tags: - Admin security: - adminToken: [] responses: '200': description: Successful response content: application/json: schema: type: object properties: message: type: string count: type: integer '401': description: Unauthorized '403': description: Forbidden '500': description: Internal Server Error /admin/tokens/{tokenPrefix}/enable: patch: summary: Enable token description: Enables a token by prefix. tags: - Admin security: - adminToken: [] parameters: - in: path name: tokenPrefix required: true schema: type: string description: The token prefix responses: '200': description: Successful response '401': description: Unauthorized '403': description: Forbidden '404': description: Token not found '500': description: Internal Server Error /admin/tokens/{tokenPrefix}/disable: patch: summary: Disable token description: Disables a token by prefix. tags: - Admin security: - adminToken: [] parameters: - in: path name: tokenPrefix required: true schema: type: string description: The token prefix responses: '200': description: Successful response '401': description: Unauthorized '403': description: Forbidden '404': description: Token not found '500': description: Internal Server Error /admin/logs: get: summary: List log files description: Lists all log files. tags: - Admin security: - adminToken: [] responses: '200': description: Successful response content: application/json: schema: type: array items: type: string '401': description: Unauthorized '403': description: Forbidden '500': description: Internal Server Error /admin/logs/{filename}: get: summary: Download log file description: Downloads a specific log file. tags: - Admin security: - adminToken: [] parameters: - in: path name: filename required: true schema: type: string description: The log filename responses: '200': description: Successful response '401': description: Unauthorized '403': description: Forbidden '404': description: File not found '500': description: Internal Server Error /admin/rss: post: summary: Update RSS feed description: Updates the RSS feed file. tags: - Admin security: - adminToken: [] requestBody: content: multipart/form-data: schema: type: object properties: rss: type: string format: binary description: RSS file to upload responses: '200': description: Successful response '400': description: No RSS file provided '401': description: Unauthorized '403': description: Forbidden '500': description: Internal Server Error /save: post: summary: Save images description: Saves uploaded images and returns a token for later retrieval. tags: - Image requestBody: content: multipart/form-data: schema: type: object properties: image: type: array items: type: string format: binary description: Image file(s) to be saved responses: '200': description: Successful response content: application/json: schema: type: object properties: id: type: string password: type: string '500': description: Internal Server Error /image/{id}&{password}: get: summary: Retrieve saved images description: Retrieves previously saved images using the provided ID and password. tags: - Image parameters: - in: path name: id required: true schema: type: string description: The image ID - in: path name: password required: true schema: type: string description: The password for image retrieval responses: '200': description: Successful response content: application/json: schema: type: object properties: image: type: array items: type: string '404': description: Image not found '500': description: Internal Server Error /rss: get: summary: Get RSS feed description: Returns the RSS feed. tags: - Misc responses: '200': description: Successful response content: application/rss+xml: schema: type: string /identify: post: summary: Identify species from image (authenticated) description: > Identifies species from uploaded images. Requires an API token. If the token was issued with a secret, the request must also be signed: build the canonical string as the lines "v1", the HTTP method, the path, the token, the timestamp and the SHA-256 of (each image's SHA-256 hex, joined by newlines, then a newline, then the body fields as key=value sorted by key and joined by newlines), joined by newlines; the signature is the HMAC-SHA256 of that string with the secret, hex encoded. Timestamps more than 300 seconds from the server clock are rejected. If the token has registered origins, requests are accepted only from those. tags: - Identification security: - apiToken: [] parameters: - in: header name: X-Artsorakel-Timestamp schema: type: string required: false description: Unix time in seconds. Required for tokens that have a secret. - in: header name: X-Artsorakel-Signature schema: type: string required: false description: > v1=. Required for tokens that have a secret. requestBody: content: multipart/form-data: schema: type: object properties: image: type: array items: type: string format: binary description: Image file(s) to be analyzed application: type: string description: Name of the application making the request responses: '200': description: Successful response content: application/json: schema: type: object properties: predictions: type: array items: type: object uploadId: type: string uploadSecret: type: string '401': description: Unauthorized '403': description: Forbidden '500': description: Internal Server Error /admin/tokens/{tokenPrefix}/secret: post: summary: Create or rotate a token's signing secret description: > Generates a new secret for the token and returns it once. Any existing secret is kept as the previous secret and stays valid until retired, so a consumer can switch over at its own pace. A token that gains a secret must sign every request from that moment on. tags: - Admin security: - adminToken: [] parameters: - in: path name: tokenPrefix required: true schema: type: string description: The first characters of the token, enough to identify it uniquely responses: '200': description: Successful response content: application/json: schema: type: object properties: message: type: string token: type: string name: type: string application: type: string secret: type: string previousSecretAccepted: type: boolean warning: type: string '400': description: Ambiguous token prefix '401': description: Unauthorized '403': description: Forbidden '404': description: Token not found '500': description: Internal Server Error /admin/tokens/{tokenPrefix}/secret/previous: delete: summary: Retire the previous signing secret description: > Stops accepting the secret that was replaced by the last rotation. Idempotent when there is none. tags: - Admin security: - adminToken: [] parameters: - in: path name: tokenPrefix required: true schema: type: string responses: '200': description: Successful response content: application/json: schema: type: object properties: message: type: string token: type: string name: type: string '400': description: Ambiguous token prefix '401': description: Unauthorized '403': description: Forbidden '404': description: Token not found '500': description: Internal Server Error /admin/tokens/{tokenPrefix}/origins: post: summary: Restrict a token to an origin description: > Adds a browser origin the token may be used from. While a token has at least one origin, requests are accepted only from those origins and the response echoes the matching origin instead of a wildcard. Adding an origin retires the token's signing secret, since a browser cannot keep one. tags: - Admin security: - adminToken: [] parameters: - in: path name: tokenPrefix required: true schema: type: string requestBody: required: true content: application/json: schema: type: object properties: origin: type: string description: Full URL, for example https://orakel.efugl.no responses: '200': description: Successful response content: application/json: schema: type: object properties: message: type: string token: type: string name: type: string allowedOrigins: type: array items: type: string signingRequired: type: boolean '400': description: Malformed origin or ambiguous token prefix '401': description: Unauthorized '403': description: Forbidden '404': description: Token not found '500': description: Internal Server Error delete: summary: Remove an origin restriction description: > Removes one origin. When the last one is removed the token is accepted from anywhere again. The retired signing secret is not restored. tags: - Admin security: - adminToken: [] parameters: - in: path name: tokenPrefix required: true schema: type: string requestBody: required: true content: application/json: schema: type: object properties: origin: type: string responses: '200': description: Successful response content: application/json: schema: type: object properties: message: type: string token: type: string name: type: string allowedOrigins: type: array items: type: string '400': description: Malformed origin or ambiguous token prefix '401': description: Unauthorized '403': description: Forbidden '404': description: Token not found '500': description: Internal Server Error /admin/ipwatch: get: summary: List watched IP buckets description: > Request logs record the caller's address as four hexadecimal characters of a keyed hash rather than the address itself. A bucket can be watched temporarily to see the addresses behind it. tags: - Admin security: - adminToken: [] responses: '200': description: Successful response content: application/json: schema: type: object properties: buckets: type: array items: type: string '401': description: Unauthorized '403': description: Forbidden /admin/ipwatch/{bucket}: post: summary: Start watching an IP bucket description: > While a bucket is watched, every matching request is also written to ipwatch-_.csv with the full address, origin, log file and user agent. tags: - Admin security: - adminToken: [] parameters: - in: path name: bucket required: true schema: type: string description: Four hexadecimal characters, as found in the IP_bucket log column responses: '200': description: Successful response content: application/json: schema: type: object properties: message: type: string buckets: type: array items: type: string '400': description: Not a four character hexadecimal bucket '401': description: Unauthorized '403': description: Forbidden delete: summary: Stop watching an IP bucket tags: - Admin security: - adminToken: [] parameters: - in: path name: bucket required: true schema: type: string responses: '200': description: Successful response content: application/json: schema: type: object properties: message: type: string buckets: type: array items: type: string '401': description: Unauthorized '403': description: Forbidden /taxon/description/{sciNameId}: get: summary: Get a taxon description description: Returns the cached name record for a scientific name id. tags: - Taxon parameters: - in: path name: sciNameId required: true schema: type: string responses: '200': description: Successful response '404': description: Not found '500': description: Internal Server Error /taxon/description/random/id: get: summary: Get a random taxon description description: Returns the name record of a randomly chosen cached taxon. tags: - Taxon responses: '200': description: Successful response '500': description: Internal Server Error /taxon/description/view: get: summary: Taxon description browser description: Human readable page for inspecting cached taxon descriptions. tags: - Taxon responses: '200': description: HTML page /robots933456.txt: get: summary: Azure health probe description: Returns a fixed string. Reserved by Azure App Service, not a real robots file. tags: - Utility responses: '200': description: Plain text response