Monica
Log in
API v1
v1
View as Markdown

List the contacts of a file

GET QUERY /api/v1/imports/{accountImport}/contacts

List the contacts a file holds, by name, to choose which of them is you.

The id of each is what me_contact takes when the import is started. The list is empty while the file is read.

This endpoint answers GET and QUERY alike, and both return the same answer. GET sends the parameters in the address, QUERY in the request body. How QUERY works.

Parameters

Path parameters go in the address. GET sends the others in the address too, QUERY sends them as JSON in the request body. Anything not listed here is ignored.

accountImport uuid Required

The id of the import. One belonging to another account answers 404.

search string Optional

Only the contacts whose name holds these letters, in capitals or not.

page integer Optional default: 1

Which page to answer with.

per_page integer Optional default: 25

How many records one page holds, between 1 and 100. A number outside the range is brought back into it rather than refused.

Returns

A page of the contacts of the file, sorted by name. An import of another account answers 404.

data array

The contacts of the file on this page. An empty list rather than an error when there are none.

data[] object

One contact of the file.

data[].type string

Always account_import_contact. It names the kind of record, so a caller holding several kinds can tell them apart without looking at where they came from.

data[].id string

The id of this record, as a string even when it reads as a number. It is what every endpoint naming this record takes.

data[].attributes object

Everything the record holds.

data[].attributes.name string

The first and last name the file gives the contact, or null when it gives none.

meta object

Where you are in the collection.

meta.page integer

The page this is, counting from 1.

meta.per_page integer

How many one page holds, which is the size that was asked for once it has been brought into the allowed range.

meta.total integer

How many contacts of the file there are in all, not how many are on this page.

Status codes

Every code the API answers with, and what the body holds when it does.

Code When Body
422 Unprocessable Content With QUERY, a parameter was sent both in the address and in the body. A message, and an errors object naming each parameter sent twice.

Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in X-RateLimit-Remaining.

GET
curl https://friends.ban.is/api/v1/imports/3f8a1c52-7d4e-4b19-9a06-c2e5b8d71f40/contacts?search=Schrute&page=2&per_page=10 \
-H "Authorization: Bearer $MONICA_TOKEN"
const response = await fetch('https://friends.ban.is/api/v1/imports/3f8a1c52-7d4e-4b19-9a06-c2e5b8d71f40/contacts?search=Schrute&page=2&per_page=10', {
headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
$response = Http::withToken($token)->get('https://friends.ban.is/api/v1/imports/3f8a1c52-7d4e-4b19-9a06-c2e5b8d71f40/contacts?search=Schrute&page=2&per_page=10');
QUERY
curl https://friends.ban.is/api/v1/imports/3f8a1c52-7d4e-4b19-9a06-c2e5b8d71f40/contacts \
-X QUERY \
-H "Authorization: Bearer $MONICA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"search": "Schrute",
"page": 2,
"per_page": 10
}'
const response = await fetch('https://friends.ban.is/api/v1/imports/3f8a1c52-7d4e-4b19-9a06-c2e5b8d71f40/contacts', {
method: 'QUERY',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
search: 'Schrute',
page: 2,
per_page: 10,
}),
})
const data = await response.json()
$response = Http::withToken($token)->query('https://friends.ban.is/api/v1/imports/3f8a1c52-7d4e-4b19-9a06-c2e5b8d71f40/contacts', [
'search' => 'Schrute',
'page' => 2,
'per_page' => 10,
]);
Response 200
{
"data": [
{
"type": "account_import_contact",
"id": "10000000-0000-4000-8000-000000000002",
"attributes": {
"name": "Dwight Schrute"
}
}
],
"meta": {
"page": 1,
"per_page": 25,
"total": 1
}
}

Keys act as you, with exactly the access you have. Make one per integration so you can revoke it alone.