Skip to content

API Specification

William Garneau edited this page Oct 7, 2024 · 5 revisions

API Specification

Overview

This document outlines the API specification for the Veri-Fact.ai misinformation detection and mitigation system.

  • Base URL: https://api.veri-fact.ai/v1
  • Authentication: Bearer Token (JWT)

Authentication

All endpoints require Bearer token authentication unless specified otherwise.

Endpoints

1. Users

Create User

  • POST /users/
  • Auth required: No
  • Request Body:
    {
      "username": "string",
      "email": "string"
    }
  • Response:
    {
      "id": "uuid",
      "username": "string",
      "email": "string",
      "auth0_id": "string",
      "created_at": "timestamp",
      "last_login": "timestamp"
    }

Get User

  • GET /users/{user_id}
  • Response: Same as Create User response

2. Claims

Create Claim

  • POST /claims/
  • Request Body:
    {
      "user_id": "uuid",
      "claim_text": "string",
      "context": "string"
    }
  • Response:
    {
      "id": "uuid",
      "user_id": "uuid",
      "claim_text": "string",
      "context": "string",
      "created_at": "timestamp"
    }

Get Claim

  • GET /claims/{claim_id}
  • Response: Same as Create Claim response

3. Analysis

Create Analysis

  • POST /analysis/
  • Request Body:
    {
      "claim_id": "uuid",
      "veracity_score": 0.0,
      "confidence_score": 0.0,
      "analysis_text": "string"
    }
  • Response:
    {
      "id": "uuid",
      "claim_id": "uuid",
      "veracity_score": 0.0,
      "confidence_score": 0.0,
      "analysis_text": "string",
      "created_at": "timestamp"
    }

Get Analysis

  • GET /analysis/{analysis_id}
  • Response: Same as Create Analysis response

4. Sources

Create Source

  • POST /sources/
  • Request Body:
    {
      "analysis_id": "uuid",
      "url": "string",
      "title": "string",
      "snippet": "string",
      "credibility_score": 0.0
    }
  • Response:
    {
      "id": "uuid",
      "analysis_id": "uuid",
      "url": "string",
      "title": "string",
      "snippet": "string",
      "credibility_score": 0.0
    }

Get Source

  • GET /sources/{source_id}
  • Response: Same as Create Source response

5. Feedback

Create Feedback

  • POST /feedback/
  • Request Body:
    {
      "analysis_id": "uuid",
      "user_id": "uuid",
      "rating": 0.0,
      "comment": "string"
    }
  • Response:
    {
      "id": "uuid",
      "analysis_id": "uuid",
      "user_id": "uuid",
      "rating": 0.0,
      "comment": "string",
      "created_at": "timestamp"
    }

Get Feedback

  • GET /feedback/{feedback_id}
  • Response: Same as Create Feedback response

6. Conversations

Create Conversation

  • POST /conversations/
  • Request Body:
    {
      "user_id": "uuid"
    }
  • Response:
    {
      "id": "uuid",
      "user_id": "uuid",
      "start_time": "timestamp",
      "end_time": "timestamp or null",
      "status": "string"
    }

Get Conversation

  • GET /conversations/{conversation_id}
  • Response: Same as Create Conversation response

7. Messages

Create Message

  • POST /messages/
  • Request Body:
    {
      "conversation_id": "uuid",
      "sender_type": "string",
      "content": "string",
      "claim_id": "uuid or null",
      "analysis_id": "uuid or null"
    }
  • Response:
    {
      "id": "uuid",
      "conversation_id": "uuid",
      "sender_type": "string",
      "content": "string",
      "timestamp": "timestamp",
      "claim_id": "uuid or null",
      "analysis_id": "uuid or null"
    }

Get Message

  • GET /messages/{message_id}
  • Response: Same as Create Message response

Get Messages by Conversation

  • GET /messages/conversation/{conversation_id}
  • Response:
    [
      {
        "id": "uuid",
        "conversation_id": "uuid",
        "sender_type": "string",
        "content": "string",
        "timestamp": "timestamp",
        "claim_id": "uuid or null",
        "analysis_id": "uuid or null"
      }
    ]

8. Domains

Create Domain

  • POST /domains/
  • Request Body:
    {
      "domain_name": "string",
      "credibility_score": 0.0,
      "is_reliable": true,
      "description": "string or null"
    }
  • Response:
    {
      "id": "uuid",
      "domain_name": "string",
      "credibility_score": 0.0,
      "is_reliable": true,
      "description": "string or null",
      "created_at": "timestamp",
      "updated_at": "timestamp"
    }

Get Domain

  • GET /domains/{domain_id}
  • Response: Same as Create Domain response

Get Domain by Name

  • GET /domains/name/{domain_name}
  • Response: Same as Create Domain response

Update Domain

  • PUT /domains/{domain_id}
  • Request Body: Same as Create Domain request
  • Response: Same as Create Domain response

Delete Domain

  • DELETE /domains/{domain_id}
  • Response:
    {
      "success": true
    }

Error Responses

All endpoints can return the following error responses:

  • 404 Not Found: When the requested resource is not found.
  • 422 Unprocessable Entity: When the request body fails validation.

Error response body:

{
  "detail": "Error description"
}

This API specification reflects the current implementation of the misinformation mitigation system's backend, including all endpoints for users, claims, analysis, sources, feedback, conversations, messages, and domains.