self-contained contacts API for searching through VCF for contact records
Project description
contactlookup
Self hosted contacts API for searching through a VCF file for contact records
Installation
Using pip:
pip install contactlookup
Using poetry:
poetry add contactlookup
Using pipenv:
pipenv install contactlookup
Quick Start
Running as a Docker container
Serve the contacts in the accompanying contacts.vcf file:
docker build -t contactlookup .
docker run -p 8000:8000 contactlookup # This uses the contacts.vcf file in the container
# Daemonize the container
docker run -d -p 8000:8000 contactlookup
If you want to use a different VCF file, you can mount it as a volume:
docker run -d -p 8000:8000 -v /path/to/contacts.vcf:/app/contacts.vcf contactlookup
:warning: The VCF file must be mounted at /app/contacts.vcf
in the container.
To stop the container:
docker ps # Get the container ID
docker stop <container_id>
Running as a CLI application
As a script:
contactlookup --help
contactlookup # Start the API server, and serve the contacts in the accompanying contacts.vcf file
contactlookup -f /path/to/contacts.vcf # Start the API server, and serve the contacts in the VCF file
As a module:
python -m contactlookup --help
Using the API
You can search for contacts by
- first name,
- phone number, or
- email address.
The search is case-insensitive. Partial matches are not yet supported.
Search using web browser
Open your web browser and navigate to http://localhost:8000/docs
to see the
API documentation. Depending on your setup, you may need to replace localhost
.
Search using curl
Search by email
curl -X 'GET' \
'http://localhost:8000/contacts/email/jeffnewman@example.net' \
-H 'accept: application/json'
Search by phone number
curl -X 'GET' \
'http://localhost:8000/contacts/phone/+993-547-8840782' \
-H 'accept: application/json'
The use of +
, -
, .
, and ()
in the phone number is optional.
Response:
{
"contacts": [
{
"id": 1,
"first_name": "KRISTEN",
"last_name": "PEREZ",
"other_names": null,
"company": "Crescendo Associates",
"title": null,
"nickname": "NICKNAME",
"birthday": "1966-08-19",
"phone_numbers": [
{
"id": null,
"number": "7194259182505",
"contact_id": 1,
"type": null
},
{
"id": null,
"number": "9935478840782",
"contact_id": 1,
"type": null
}
],
"addresses": [
{
"id": null,
"street": "36346 Hall Stream",
"city": "CHRISTOPHERSTAD",
"state": "CA",
"postal_code": "73297",
"contact_id": 1,
"type": null,
"country": "USA"
},
{
"id": null,
"street": "196 Purple Sage Cres",
"city": "WINNIPEG",
"state": "MB",
"postal_code": "R3X 1V7",
"contact_id": 1,
"type": null,
"country": "CA"
}
],
"emails": [
{
"id": null,
"email": "jacksonkimberly@example.net",
"type": null,
"contact_id": 1
}
]
}
]
}
Search by first name
curl -X 'GET' \
'http://localhost:8000/contacts/fname/jeff' \
-H 'accept: application/json'
Results are returned in JSON format:
{
"contacts": [
{
"id": 3,
"first_name": "JEFF",
"last_name": "",
"other_names": null,
"company": "Viagenie",
"title": null,
"nickname": null,
"birthday": "1949-01-29",
"phone_numbers": [
{
"id": null,
"number": "3632144414254",
"contact_id": 3,
"type": null
}
],
"addresses": [
{
"id": null,
"street": "2360 Bean Tunnel",
"city": "SOUTH JAMES",
"state": "DC",
"postal_code": "96916",
"contact_id": 3,
"type": null,
"country": "MONTSERRAT"
},
{
"id": null,
"street": "26767 Khan Dam",
"city": "EAST MARISAMOUTH",
"state": "MA",
"postal_code": "26701",
"contact_id": 3,
"type": null,
"country": "BRAZIL"
},
{
"id": null,
"street": "63932 Natasha Fords",
"city": "DEBRAVIEW",
"state": "VT",
"postal_code": "22957",
"contact_id": 3,
"type": null,
"country": "NAMIBIA"
}
],
"emails": [
{
"id": null,
"email": "allentaylor@example.net",
"type": null,
"contact_id": 3
},
{
"id": null,
"email": "daniel03@example.net",
"type": null,
"contact_id": 3
},
{
"id": null,
"email": "martinezveronica@example.net",
"type": null,
"contact_id": 3
}
]
},
{
"id": 4,
"first_name": "JEFF",
"last_name": "NEWMAN",
"other_names": null,
"company": "Hollywood",
"title": null,
"nickname": null,
"birthday": "1955-03-29",
"phone_numbers": [
{
"id": null,
"number": "161555531122",
"contact_id": 4,
"type": null
}
],
"addresses": [
{
"id": null,
"street": "123 Hollywood St",
"city": "BEVERLEY-HILLS",
"state": "CA",
"postal_code": "22957",
"contact_id": 4,
"type": null,
"country": "USA"
}
],
"emails": [
{
"id": null,
"email": "jeffnewman@example.net",
"type": null,
"contact_id": 4
}
]
}
]
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file contactlookup-2.0.1.tar.gz
.
File metadata
- Download URL: contactlookup-2.0.1.tar.gz
- Upload date:
- Size: 28.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f388e41786dc3947ea561fb1efc7e754a126099e938e404a04e1b99a097b9d79 |
|
MD5 | 09158b09ca344690df0fa1131703a8fa |
|
BLAKE2b-256 | 3acdfd51fef102feea8b093c68f511f663c30fd7813107ae003d9bdaf6ff08c0 |
File details
Details for the file contactlookup-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: contactlookup-2.0.1-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55e8f74a04a9ed36980b968a5e0ef82c40829ef3bf7e07bb64bf81acaa8c8036 |
|
MD5 | 83f306e57d191b61eaf64844bb0add30 |
|
BLAKE2b-256 | 38e0a7a5d2e96bdad32da9c15f0a65c3ecd4db4ea6d0f0fe566b89c33e3f4fff |