Skip to main content

GET /api/readme-history

Retrieves all README files previously generated by the authenticated user, ordered by creation date (newest first).

Authentication

This endpoint requires authentication. Include valid Clerk authentication credentials in your request.

Response

history
array
Array of generated README records
id
string
Unique identifier for the README record
user_id
string
Clerk user ID of the user who generated the README
repo_url
string
The GitHub repository URL for which the README was generated
readme_content
string
The generated README content in Markdown format
created_at
string
ISO 8601 timestamp of when the README was generated

Code examples

curl -X GET https://gitread.dev/api/readme-history \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Response example

{
  "history": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "user_id": "user_2abc123xyz",
      "repo_url": "https://github.com/facebook/react",
      "readme_content": "# React\n\nA JavaScript library for building user interfaces...\n",
      "created_at": "2026-02-28T10:30:00.000Z"
    },
    {
      "id": "660e8400-e29b-41d4-a716-446655440001",
      "user_id": "user_2abc123xyz",
      "repo_url": "https://github.com/vercel/next.js",
      "readme_content": "# Next.js\n\nThe React Framework for Production...\n",
      "created_at": "2026-02-27T15:20:00.000Z"
    }
  ]
}

Error responses

401
Unauthorized
Authentication required
{
  "error": "Unauthorized"
}
500
Internal Server Error
Error fetching README history from database
{
  "error": "Error fetching README history"
}
or
{
  "error": "Unexpected error fetching README history"
}

POST /api/readme-history

Saves a generated README to the user’s history. This endpoint is typically called after a successful README generation.

Authentication

This endpoint requires authentication. Include valid Clerk authentication credentials in your request.

Request body

repoUrl
string
required
The GitHub repository URL for which the README was generated
readmeContent
string
required
The generated README content in Markdown format

Response

success
boolean
Indicates whether the README was successfully saved

Code examples

curl -X POST https://gitread.dev/api/readme-history \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -d '{
    "repoUrl": "https://github.com/facebook/react",
    "readmeContent": "# React\n\nA JavaScript library..."
  }'

Response example

{
  "success": true
}

Error responses

400
Bad Request
Missing required fields
{
  "error": "Repository URL and README content are required"
}
This error occurs when:
  • repoUrl is not provided or is empty
  • readmeContent is not provided or is empty
401
Unauthorized
Authentication required
{
  "error": "Unauthorized"
}
500
Internal Server Error
Error saving README to database
{
  "error": "Error saving README"
}
or
{
  "error": "Unexpected error saving README"
}

Usage notes

  • README history is saved on the client side after successful generation to prevent duplicate entries
  • Each README is stored with a timestamp for chronological ordering
  • There is no automatic limit on the number of READMEs that can be saved per user
  • The user_id is automatically extracted from the authentication context

Build docs developers (and LLMs) love