8.1 KiB
__ __ ______ ___ ______ ___
__/ // /_/ ____/ __ \/ ____/ __ \
/_ // __/ __/ / /_/ / / __/ / / /
/_ // __/ /___/ _, _/ /_/ / /_/ /
/_//_/ /_____/_/ |_|\____/\____/
Ergo IRCd API Documentation
https://ergo.chat/
Copyright © Daniel Oaks daniel@danieloaks.net, Shivaram Lingamneni slingamn@cs.stanford.edu
Ergo has an experimental HTTP API. Some general information about the API:
- All requests to the API are via POST.
- All requests to the API are authenticated via bearer authentication.
This is a header named
Authorizationwith the valueBearer <token>. A list of valid tokens is hardcoded in the Ergo config. Future versions of Ergo may allow additional validation schemes for tokens. - The request parameters are sent as JSON in the POST body.
- Any status code other than 200 is an error response; the response body is undefined in this case (likely human-readable text for debugging).
- A 200 status code indicates successful execution of the request. The
response body will be JSON and may indicate application-level success or
failure (typically via the
successfield, which takes a boolean value).
API endpoints are versioned (currently all endpoints have a
/v1/ path prefix). Backwards-incompatible updates will most
likely take the form of endpoints with new names, or an increased
version prefix. Any exceptions to this will be specifically documented
in the changelog.
All API endpoints should be considered highly privileged. Bearer
tokens should be kept secret. Access to the API should be either over a
trusted link (like loopback) or secured via verified TLS. See the
api section of default.yaml for examples of
how to configure this.
Here’s an example of how to test an API configured to run over loopback TCP in plaintext:
curl -d '{"accountName": "invalidaccountname", "passphrase": "invalidpassphrase"}' -H 'Authorization: Bearer EYBbXVilnumTtfn4A9HE8_TiKLGWEGylre7FG6gEww0' -v http://127.0.0.1:8089/v1/check_authThis returns:
{"success":false}Endpoints
/v1/check_auth
This endpoint verifies the credentials of a NickServ account; this allows Ergo to be used as the source of truth for authentication by another system. The request is a JSON object with fields:
accountName: string, name of the accountpassphrase: string, alleged passphrase of the accountcertfp: string, alleged certificate fingerprint (hex-encoded SHA-256 checksum of the decoded raw certificate) associated with the account
Each individual field is optional, since a user may be authenticated either by account-passphrase pair or by certificate.
The response is a JSON object with fields:
success: whether the credentials provided were validaccountName: canonical, case-unfolded version of the account name
/v1/defcon
This endpoint can be used to view or modify the DEFCON level (see
/helpop defcon for details). If the request is empty, the
existing level is returned. To change the level, send a JSON object with
fields:
defcon: integer, desired new value of the DEFCON setting (between 5 for normal operation and 1 for the most restrictive)
The response is a JSON object with fields:
defcon: integer, current (or new) value of the DEFCON setting
/v1/list
This endpoint returns a list of channels that exist on the network. The request body is ignored and can be empty.
The response is a JSON object with fields:
success: whether the request was successfulchannels: a list of channel objects, as described below
Each channel object has fields:
name: canonical name of the channel without case-normalizationhasKey: boolean, whether the channel has a key set with the+kmodeinviteOnly: boolean, whether the channel has the+iinvite-only mode setsecret: boolean, whether the channel has the+ssecret mode set (and would be hidden from an unprivilegedLISTcommand)userCount: integer, number of users in the channeltopic: string, channel topictopicSetAt: string, time the topic was last updated (in ISO8601 format)createdAt: string, time the channel was created (in ISO8601 format)registered: boolean, whether the channel is registeredowner: string, account name of the registered owner if the channel is registeredregisteredAt: string, registration date/time of the channel (in ISO8601 format) if it is registered
/v1/ns/info
This endpoint fetches account details and returns them as JSON. The request is a JSON object with fields:
accountName: string, name of the account
The response is a JSON object with fields:
success: whether the account exists or notaccountName: canonical, case-unfolded version of the account nameemail: email address of the account providedregisteredAt: string, registration date/time of the account (in ISO8601 format)channels: array of strings, list of channels the account is registered on or associated with
Note: this endpoint was previously named
/v1/account_details. The old name is still accepted for
backwards compatibility.
/v1/ns/list
This endpoint fetches a list of all accounts. The request body is ignored and can be empty.
The response is a JSON object with fields:
success: whether the request succeededaccounts: array of objects, each with fields:success: boolean, whether this individual account query succeededaccountName: string, canonical, case-unfolded version of the account name
totalCount: integer, total number of accounts returned
Note: this endpoint was previously named
/v1/account_list. The old name is still accepted for
backwards compatibility.
/v1/ns/passwd
This endpoint changes the password of an existing NickServ account. The request is a JSON object with fields:
accountName: string, name of the accountpassphrase: string, new passphrase for the account
The response is a JSON object with fields:
success: whether the password change succeedederrorCode: string, optional, machine-readable description of the error. Possible values include:ACCOUNT_DOES_NOT_EXIST,INVALID_PASSPHRASE,CREDENTIALS_EXTERNALLY_MANAGED,UNKNOWN_ERROR.
/v1/ns/saregister
This endpoint registers an account in NickServ, with the same
semantics as NS SAREGISTER. The request is a JSON object
with fields:
accountName: string, name of the accountpassphrase: string, passphrase of the account
The response is a JSON object with fields:
success: whether the account creation succeedederrorCode: string, optional, machine-readable description of the error. Possible values include:ACCOUNT_EXISTS,INVALID_PASSPHRASE,UNKNOWN_ERROR.error: string, optional, human-readable description of the failure.
Note: this endpoint was previously named /v1/saregister.
The old name is still accepted for backwards compatibility.
/v1/rehash
This endpoint rehashes the server (i.e. reloads the configuration file, TLS certificates, and other associated data). The body is ignored. The response is a JSON object with fields:
success: boolean, indicates whether the rehash was successfulerror: string, optional, human-readable description of the failure
/v1/status
This endpoint returns status information about the running Ergo server. The request body is ignored and can be empty.
The response is a JSON object with fields:
success: whether the request succeededversion: string, Ergo server version stringgo_version: string, version of Go runtime usedstart_time: string, server start time in ISO8601 formatusers: object with fields:total: total number of users connectedinvisible: number of invisible usersoperators: number of operators connectedunknown: number of users with unknown statusmax: maximum number of users seen connected at once
channels: integer, number of channels currently activeservers: integer, number of servers connected in the network