Skip to content

influqa/influqa_api_demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Influqa API Demo

A demonstration of the Influqa Influencer Marketing Platform API with Role-Based Access Control (RBAC).

Based on the pricing plans available on the platform.

πŸ‘₯ User Types

The platform supports 5 user types:

User Type Description Can Create Campaigns
✨ Influencer Creator profile No
πŸ’Ό Business Companies & brands Yes
πŸ‘₯ Agency Talent management No
❀️ Nonprofit Non-profit organizations Yes
πŸŽ“ Education Educational institutions Yes

πŸ’Ž VIP Tiers

Each user type can subscribe to different tiers:

Tier Price Description
Basic FREE Limited API access
SVIP $4.99/mo Enhanced features
GVIP $19.99/mo Full platform access

πŸ” Access Control

User Type Influencers Campaigns Offers Analytics
Influencer Own only Hired in only Received only Own performance
Business Partnered only Own only Sent only Own campaigns
Agency Managed only Related Received by managed Related
Nonprofit None Own only Sent only Own campaigns
Education None Own only Sent only Own campaigns

Access Rules

  1. Influencer users can only see:

    • Their own profile
    • Campaigns they're hired in
    • Offers they received
  2. Business users can only see:

    • Their own campaigns
    • Influencers they work with (hired in their campaigns)
    • Offers they sent
  3. Agency users can only see:

    • Influencers they manage
    • Offers received by their managed influencers
    • Campaigns their influencers are hired in
  4. Nonprofit/Education users have limited access:

    • Only their own campaigns
    • No influencer discovery

πŸ“‹ API Endpoints

Authentication

Method Endpoint Description
GET /auth/verify Verify API key and get access summary
GET /auth/demo-keys List all demo API keys

Influencer Discovery

Method Endpoint Description
GET /influencers List influencers (filtered by access)
GET /influencers/{id} Get influencer details
GET /influencers/{id}/offers Get influencer's offers

Campaign Management

Method Endpoint Description
GET /campaigns List campaigns (filtered by access)
GET /campaigns/{id} Get campaign details
POST /campaigns Create new campaign
PATCH /campaigns/{id}/status Update campaign status
DELETE /campaigns/{id} Delete campaign

Analytics

Method Endpoint Description
GET /analytics/overview Get overview statistics
GET /analytics/campaigns/{id} Get campaign analytics
GET /analytics/influencers/{id} Get influencer analytics

πŸš€ Quick Start

1. Clone & Install

git clone https://github.com/influqa/influqa_api_demo.git
cd influqa_api_demo
pip install -r requirements.txt

2. Run the Server

uvicorn main:app --reload

3. Explore the API

Open http://localhost:8000/docs for interactive Swagger UI.

πŸ”‘ Demo API Keys

Use these keys in the X-API-Key header:

API Key User Type VIP Tier Access Level
demo_key_influencer Influencer SVIP Own profile + 1 campaign + offers
demo_key_business Business GVIP 2 campaigns + 2 partnered influencers
demo_key_agency Agency GVIP 3 managed influencers + their offers
demo_key_nonprofit Nonprofit SVIP 1 campaign
demo_key_education Education Basic 1 campaign (draft)

πŸ“ Example Requests

Verify API Key

curl -X GET "http://localhost:8000/auth/verify" \
  -H "X-API-Key: demo_key_agency"

Response:

{
  "success": true,
  "message": "API key is valid",
  "user": {
    "user_id": "user_agency_001",
    "user_type": "agency",
    "vip_tier": "gvip",
    "company_name": "Creative Talent Agency"
  },
  "access_summary": {
    "accessible_influencers": 3,
    "accessible_campaigns": 2,
    "accessible_offers": 4
  }
}

List Influencers (Agency)

curl -X GET "http://localhost:8000/influencers" \
  -H "X-API-Key: demo_key_agency"

Returns only the 3 influencers managed by this agency.

List Campaigns (Business)

curl -X GET "http://localhost:8000/campaigns" \
  -H "X-API-Key: demo_key_business"

Returns only campaigns owned by this business.

Access Denied Example

curl -X GET "http://localhost:8000/influencers/inf_003" \
  -H "X-API-Key: demo_key_agency"

Response (403 Forbidden):

{
  "detail": "Access denied. You don't have permission to view influencer inf_003."
}

πŸ—οΈ Project Structure

influqa_api_demo/
β”œβ”€β”€ main.py              # FastAPI application entry point
β”œβ”€β”€ auth.py              # Authentication utilities
β”œβ”€β”€ models.py            # Pydantic models
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ README.md            # This file
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── sample_data.py   # Mock data + access control functions
β”œβ”€β”€ routers/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ auth.py          # Authentication endpoints
β”‚   β”œβ”€β”€ influencers.py   # Influencer discovery endpoints
β”‚   β”œβ”€β”€ campaigns.py     # Campaign management endpoints
β”‚   └── analytics.py     # Analytics endpoints
β”œβ”€β”€ examples/
β”‚   └── basic_usage.py   # Basic API usage examples
└── tests/
    └── test_api.py      # Test suite

πŸ”’ Access Control Implementation

The access control is implemented through helper functions in data/sample_data.py:

def get_user_accessible_influencer_ids(user: dict) -> list:
    """
    Get list of influencer IDs the user can access.
    
    - business: Influencers they work with
    - agency: Influencers they manage
    - influencer: Only themselves
    - nonprofit/education: Empty (no access)
    """

Each endpoint uses these functions to filter results:

@router.get("/influencers")
async def list_influencers(user: dict = get_current_user):
    accessible_ids = get_user_accessible_influencer_ids(user)
    influencers = [inf for inf in SAMPLE_INFLUENCERS if inf["id"] in accessible_ids]
    return {"data": influencers}

πŸ§ͺ Testing

# Run tests
pytest tests/test_api.py -v

# Test with different user types
pytest tests/test_api.py -v -k "test_agency_access"

πŸ“š Documentation

🀝 Integration

To integrate with the real Influqa API:

  1. Replace demo data with real API calls
  2. Update authentication to use real API keys
  3. Implement proper database queries
  4. Add rate limiting and caching

πŸ“„ License

MIT License - See LICENSE file for details.


Built with ❀️ by the Influqa team

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages