Complete API Reference

ZKAuth API Reference

Complete REST API documentation for ZKAuth. All endpoints, authentication methods, and response formats.

Base URL

All API requests should be made to the following base URL

Production API

text
https://api.zkauth.com

All API endpoints are relative to this base URL

Authentication Methods

Choose the authentication method that works best for your use case

Bearer Token

Include your API key in the Authorization header

text
Authorization: Bearer zka_live_your_api_key

Header

Include your API key in the x-api-key header

text
x-api-key: zka_live_your_api_key

Query Parameter

Include your API key as a query parameter

text
?api_key=zka_live_your_api_key

API Endpoints

Complete list of available API endpoints

POST
None
/api/v1/auth/signup

Register a new user

Request Body

json
{
  "email": "string",
  "password": "string"
}

Response

json
{
  "success": "boolean",
  "user": "User object"
}
POST
None
/api/v1/auth/signin

Authenticate user with ZK proof

Request Body

json
{
  "email": "string",
  "password": "string"
}

Response

json
{
  "success": "boolean",
  "session": "Session object"
}
POST
Bearer Token
/api/v1/auth/verify

Verify session token

Request Body

json
{
  "token": "string"
}

Response

json
{
  "valid": "boolean",
  "user": "User object"
}
POST
Bearer Token
/api/v1/auth/signout

Invalidate session

Request Body

json
{
  "token": "string"
}

Response

json
{
  "success": "boolean"
}
GET
Bearer Token
/api/v1/user/profile

Get user profile

Request Body

json
"None"

Response

json
{
  "user": "User object"
}
PUT
Bearer Token
/api/v1/user/profile

Update user profile

Request Body

json
{
  "name": "string",
  "avatar": "string"
}

Response

json
{
  "success": "boolean",
  "user": "User object"
}

Code Examples

See how to use the API in different languages

cURL

bash
curl -X POST https://api.zkauth.com/api/v1/auth/signup \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer zka_live_your_api_key" \
  -d '{
    "email": "user@example.com",
    "password": "secure_password"
  }'

JavaScript

javascript
const response = await fetch('https://api.zkauth.com/api/v1/auth/signup', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer zka_live_your_api_key'
  },
  body: JSON.stringify({
    email: 'user@example.com',
    password: 'secure_password'
  })
});

const data = await response.json();
console.log(data);

Python

python
import requests

response = requests.post(
    'https://api.zkauth.com/api/v1/auth/signup',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer zka_live_your_api_key'
    },
    json={
        'email': 'user@example.com',
        'password': 'secure_password'
    }
)

data = response.json()
print(data)

Go

go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    payload := map[string]string{
        "email":    "user@example.com",
        "password": "secure_password",
    }

    jsonData, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST",
        "https://api.zkauth.com/api/v1/auth/signup",
        bytes.NewBuffer(jsonData))

    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer zka_live_your_api_key")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    fmt.Println(result)
}

Rust

rust
use reqwest;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();

    let response = client
        .post("https://api.zkauth.com/api/v1/auth/signup")
        .header("Content-Type", "application/json")
        .header("Authorization", "Bearer zka_live_your_api_key")
        .json(&json!({
            "email": "user@example.com",
            "password": "secure_password"
        }))
        .send()
        .await?;

    let data: Value = response.json().await?;
    println!("{:?}", data);

    Ok(())
}

Vue.js

vue
<template>
  <div>
    <button @click="signUp" :disabled="loading">
      {{ loading ? 'Signing up...' : 'Sign Up' }}
    </button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loading: false
    }
  },
  methods: {
    async signUp() {
      this.loading = true;
      try {
        const response = await fetch('https://api.zkauth.com/api/v1/auth/signup', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer zka_live_your_api_key'
          },
          body: JSON.stringify({
            email: 'user@example.com',
            password: 'secure_password'
          })
        });

        const data = await response.json();
        console.log('User created:', data);
      } catch (error) {
        console.error('Sign up failed:', error);
      } finally {
        this.loading = false;
      }
    }
  }
}
</script>

Ready to Integrate?

Start building secure applications with ZKAuth today.