SnipShare API

DISCLAIMER: ALWAYS CHECK THE CODE YOU USE FOR MALICIOUS SOFTWARE. WE DO NOT GUARANTEE THAT ALL CODES ARE SAFE. IF YOU FIND MALICIOUS SOFTWARE, REPORT IT ON THE DISCORD.

A simple RESTful API for searching, sharing, and upvoting code snippets. Perfect for developers who want to quickly find and contribute reusable code.

Endpoints

POST /snippets
Add a new code snippet.
Body:
{
  "title": "Hello World in Python",
  "code": "print('Hello, world!')",
  "language": "python",
  "tags": ["beginner", "example"]
}
GET /snippets
Search snippets by query, language, or tag.
Example: /snippets?query=hello&language=python
GET /snippets/random
Get a random code snippet.
POST /snippets/{id}/upvote
Upvote a snippet by its ID.

Try it out

Run the API with uvicorn main:app --reload and visit /docs for interactive documentation.

Example Response

{
  "id": "...",
  "title": "Hello World in Python",
  "code": "print('Hello, world!')",
  "language": "python",
  "tags": ["beginner", "example"],
  "upvotes": 0
}