Note: This project was created for learning purposes to practice Go. It is not intended for production use.
A RESTful API for managing bookmarks with user authentication, built primarily with the Go standard library.
- User Authentication: Secure user registration and login using JWT tokens.
- Bookmark Management: Full CRUD (Create, Read, Update, Delete) operations for bookmarks.
- Tagging System: Organize bookmarks with tags.
- Powerful Search: Filter bookmarks by tags or search through titles, descriptions, and notes.
- Pagination: Efficiently browse through large collections of bookmarks.
- SQLite Backend: Uses a lightweight and file-based SQLite database for storage.
- Go (version 1.20 or higher recommended)
- SQLite
-
Clone the repository:
git clone https://github.com/your-username/bookmarks-manager-api.git cd bookmarks-manager-api
-
Install dependencies:
go mod tidy
-
Run the server:
go run cmd/serve.go
The API will be available at
http://localhost:3000
.
A brief overview of the available endpoints. For detailed information, please refer to the OpenAPI Specification or the Project Specifications.
POST /api/auth/register
: Register a new user.POST /api/auth/login
: Log in and receive a JWT token.GET /api/auth/me
: Get the current user's profile.
GET /api/bookmarks
: List all bookmarks with filtering and pagination.POST /api/bookmarks
: Create a new bookmark.GET /api/bookmarks/{id}
: Get a single bookmark by its ID.PUT /api/bookmarks/{id}
: Update a bookmark.DELETE /api/bookmarks/{id}
: Delete a bookmark.
GET /api/tags
: List all tags for the current user.DELETE /api/tags/{id}
: Delete a tag.
Here's an example of how to register a user and create a bookmark using curl
:
-
Register a new user:
curl -X POST http://localhost:3000/api/auth/register \ -H "Content-Type: application/json" \ -d '{' "username": "testuser", "email": "[email protected]", "password": "password123" }'
-
Log in to get a token:
curl -X POST http://localhost:3000/api/auth/login \ -H "Content-Type: application/json" \ -d '{' "email": "[email protected]", "password": "password123" }'
-
Create a bookmark (replace
YOUR_TOKEN
with the token from the login response):curl -X POST http://localhost:3000/api/bookmarks \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{' "url": "https://golang.org/", "title": "The Go Programming Language", "tags": ["go", "programming"] }'
- User: Represents a user with an ID, username, email, and password.
- Bookmark: Represents a bookmark with a URL, title, description, notes, and associated tags.
- Tag: Represents a tag with a name.
- Go: The primary programming language.
- SQLite: The database for storing data.
- JWT: For user authentication.