Snapas

From rawveg/skillsforge-marketplace · View interactive version

Snapas is an AI agent skill from the GitHub repository rawveg/skillsforge-marketplace. Snap.as API Documentation

How to use this skill

Skill file

Snap.as Skill

Comprehensive assistance with Snap.as API development, enabling photo upload and management through the Write.as suite.

When to Use This Skill

This skill should be triggered when:

Quick Reference

Authentication

All Snap.as API requests require a Write.as user access token in the Authorization header:

Authorization: Token 00000000-0000-0000-0000-000000000000

Upload Photo to Personal Account

curl https://snap.as/api/photos/upload \
  -H "Authorization: Token YOUR_ACCESS_TOKEN" \
  -F "file=@/path/to/photo.jpg"

Response (201 Created):

{
  "code": 201,
  "data": {
    "id": "abc123",
    "filename": "photo.jpg",
    "size": 245760,
    "url": "https://i.snap.as/abc123.jpg"
  }
}

Retrieve User Photos

curl -X POST https://snap.as/api/me/photos \
  -H "Authorization: Token YOUR_ACCESS_TOKEN"

Response (200 OK):

{
  "code": 200,
  "data": [
    {
      "id": "abc123",
      "filename": "photo.jpg",
      "size": 245760,
      "url": "https://i.snap.as/abc123.jpg"
    }
  ]
}

Delete Photo

curl -X POST https://snap.as/api/photos/abc123 \
  -H "Authorization: Token YOUR_ACCESS_TOKEN"

Response (200 OK):

{
  "code": 200,
  "data": {}
}

Upload Photo to Organization

curl https://snap.as/api/organizations/myorg/photos/upload \
  -H "Authorization: Token YOUR_ACCESS_TOKEN" \
  -F "file=@/path/to/photo.jpg"

Response (201 Created):

{
  "code": 201,
  "data": {
    "id": "xyz789",
    "filename": "photo.jpg",
    "size": 245760,
    "url": "https://i.snap.as/xyz789.jpg"
  }
}

Error Response Format

{
  "code": 401,
  "error_msg": "Invalid access token"
}

Go Client Library Usage

import "github.com/snapas/go-snapas"

// Initialize client
client := snapas.NewClient("YOUR_ACCESS_TOKEN")

// Upload photo
photo, err := client.UploadPhoto("/path/to/photo.jpg")
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Photo URL: %s\n", photo.URL)

Key Concepts

Authentication

Snap.as uses Write.as user access tokens for authentication. These tokens must be obtained by logging into Write.as and retrieving the user's access credentials. Include the token in the Authorization header of every API request.

Base URL

All API requests are made to https://snap.as with specific endpoint paths appended.

Photo Objects

Photo objects returned by the API contain:

Response Format

All successful API responses follow a consistent structure:

{
  "code": <HTTP_STATUS_CODE>,
  "data": <RESPONSE_DATA>
}

Failed requests return:

{
  "code": <HTTP_STATUS_CODE>,
  "error_msg": "<ERROR_MESSAGE>"
}

HTTP Status Codes

Personal vs. Organization Photos

Reference Files

This skill includes comprehensive documentation in references/:

Use view to read the API reference file when detailed information is needed about specific endpoints or response formats.

Working with This Skill

For Beginners

Start by understanding the authentication mechanism. You'll need a Write.as user access token before making any API requests. Test with simple photo uploads to your personal account before working with organizational features.

For Integration Developers

Focus on the personal photo upload and retrieval endpoints first. Implement proper error handling for common scenarios like authentication failures (401), rate limiting (429), and invalid requests (400).

For Organization Features

Once comfortable with personal uploads, explore organizational photo management. Organizations require the organization alias in the endpoint URL and appropriate access permissions.

For Go Developers

Use the official go-snapas client library available at github.com/snapas/go-snapas for a more convenient development experience with built-in error handling and type safety.

Common Patterns

Photo Upload Flow

  1. Obtain Write.as access token
  2. Prepare photo file for upload
  3. Make POST request to /api/photos/upload with multipart form data
  4. Handle response (201 Created on success)
  5. Store photo ID and URL from response

Photo Gallery Implementation

  1. Authenticate with Write.as token
  2. Retrieve all user photos via /api/me/photos
  3. Display photos using the URLs from response data
  4. Implement delete functionality using photo IDs

Error Handling Best Practices

async function uploadPhoto(file, accessToken) {
  const formData = new FormData();
  formData.append('file', file);

  try {
    const response = await fetch('https://snap.as/api/photos/upload', {
      method: 'POST',
      headers: {
        'Authorization': `Token ${accessToken}`
      },
      body: formData
    });

    const data = await response.json();

    if (!response.ok) {
      throw new Error(data.error_msg || 'Upload failed');
    }

    return data.data;
  } catch (error) {
    console.error('Photo upload error:', error);
    throw error;
  }
}

Resources

Official Library

API Endpoints

Write.as Integration

Since Snap.as is part of the Write.as suite, authentication happens through Write.as user accounts. Ensure users have valid Write.as credentials before attempting to use Snap.as features.

Notes

Troubleshooting

401 Unauthorized

403 Forbidden

429 Rate Limited

Upload Failures

Updating

To refresh this skill with updated documentation:

  1. Check https://developers.snap.as/docs/api/ for API changes
  2. Update the reference files with new endpoint information
  3. Add new code examples for any new features
  4. Test all examples to ensure they still work
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.