This project provides a Python client for interacting with the Nubela API, specifically for querying LinkedIn profiles.
- Easy-to-use interface for querying Nubela profiles
- Caching mechanism to store and reuse previous query results
- Offline mode for development and testing
- Configurable settings using environment variables
To install the required dependencies, run:
pip install requests pydantic-settings
from nubela_api import NubelaAPI, NubelaSettings
settings = NubelaSettings(api_key="your_api_key_here")
api = NubelaAPI(settings=settings, offline=False)
linkedin_url = "https://www.linkedin.com/in/example-profile" response = api.query_linkedin(linkedin_url)
print(response.full_name) print(response.occupation)
You can pass custom parameters to the API call:
custom_params = { "linkedin_profile_url": "https://www.linkedin.com/in/example-profile", "extra": "include", "skills": "include", } response = api.query(custom_params)
The client automatically caches responses. To disable caching for a specific query:
response = api.query_linkedin(linkedin_url, use_cache=False)
For development or testing, you can enable offline mode:
api = NubelaAPI(settings=settings, offline=True)
This will raise a ValueError if an API call is attempted.
You can configure the API client using environment variables:
- NUBELA_API_KEY: Your Nubela API key
- NUBELA_API_ENDPOINT: The API endpoint (default: "https://nubela.co/proxycurl/api/v2/linkedin")
The client will raise exceptions for various error conditions:
- ValueError: If the API key is missing or if trying to make an API call in offline mode
- OfflineError: Custom exception for offline-related errors (not currently used in the provided code)
Contributions are welcome! Please feel free to submit a Pull Request.
[Add your chosen license here]