> ## Documentation Index
> Fetch the complete documentation index at: https://core.anylayer.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Attestations

> Get all attestations for a specific identity

## Overview

Retrieve all attestations associated with a specific identity. This endpoint provides comprehensive access to attestations with filtering, sorting, and pagination options, making it perfect for building reputation profiles and trust verification systems.

<Tip>
  Use this endpoint to display a user's attestation collection, verify credentials, and build trust-based applications that rely on verified attributes and relationships.
</Tip>

## Parameters

<ParamField path="identity" type="string" required>
  User identity (ZKS ID or wallet address)

  <Note>
    ZKS ID is recommended for better performance and user experience
  </Note>
</ParamField>

<ParamField query="schema" type="string">
  Filter by attestation schema

  * `skill` - Skill or expertise attestations
  * `relationship` - Relationship attestations
  * `achievement` - Achievement attestations
  * `reputation` - Reputation attestations
  * `identity` - Identity verification attestations
  * `custom` - Custom schema attestations
</ParamField>

<ParamField query="issuer" type="string">
  Filter by attestation issuer (ZKS ID or wallet address)
</ParamField>

<ParamField query="status" type="string">
  Filter by attestation status

  * `active` - Active attestations (default)
  * `expired` - Expired attestations
  * `revoked` - Revoked attestations
  * `all` - All attestations regardless of status
</ParamField>

<ParamField query="category" type="string">
  Filter by attestation category
</ParamField>

<ParamField query="tags" type="string">
  Filter by tags (comma-separated)
</ParamField>

<ParamField query="public" type="boolean">
  Filter by visibility

  * `true` - Public attestations only
  * `false` - Private attestations only
  * `null` - All attestations (default)
</ParamField>

<ParamField query="limit" type="number">
  Number of attestations to return (default: 50, max: 100)
</ParamField>

<ParamField query="offset" type="number">
  Number of attestations to skip for pagination (default: 0)
</ParamField>

<ParamField query="sortBy" type="string">
  Sort attestations by field

  * `createdAt` - By creation date (default)
  * `expiry` - By expiry date
  * `trustScore` - By trust score
  * `schema` - By schema type
</ParamField>

<ParamField query="sortOrder" type="string">
  Sort order

  * `desc` - Descending (default)
  * `asc` - Ascending
</ParamField>

<ParamField query="includeMetadata" type="boolean">
  Include detailed metadata (default: true)
</ParamField>

<ParamField query="includeEvidence" type="boolean">
  Include evidence data (default: true)
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="address" type="string">
  Resolved wallet address
</ResponseField>

<ResponseField name="zksId" type="string">
  ZKS ID if available, null otherwise
</ResponseField>

<ResponseField name="attestations" type="array">
  Array of attestation objects

  <Expandable title="attestation properties">
    <ResponseField name="id" type="string">
      Attestation identifier
    </ResponseField>

    <ResponseField name="subject" type="string">
      Attested identity
    </ResponseField>

    <ResponseField name="issuer" type="string">
      Attestation issuer
    </ResponseField>

    <ResponseField name="schema" type="string">
      Attestation schema
    </ResponseField>

    <ResponseField name="data" type="object">
      Attestation data

      <Expandable title="data properties">
        <ResponseField name="title" type="string">
          Attestation title
        </ResponseField>

        <ResponseField name="description" type="string">
          Attestation description
        </ResponseField>

        <ResponseField name="category" type="string">
          Attestation category
        </ResponseField>

        <ResponseField name="value" type="string">
          Attestation value
        </ResponseField>

        <ResponseField name="metadata" type="object">
          Additional metadata
        </ResponseField>

        <ResponseField name="evidence" type="array">
          Supporting evidence
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="signature" type="string">
      Attestation signature
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp of creation
    </ResponseField>

    <ResponseField name="expiry" type="string">
      ISO 8601 timestamp of expiry (if set)
    </ResponseField>

    <ResponseField name="revocable" type="boolean">
      Whether attestation can be revoked
    </ResponseField>

    <ResponseField name="public" type="boolean">
      Whether attestation is publicly visible
    </ResponseField>

    <ResponseField name="status" type="string">
      Attestation status (active, expired, revoked)
    </ResponseField>

    <ResponseField name="tags" type="array">
      Attestation tags
    </ResponseField>

    <ResponseField name="verification" type="object">
      Verification details

      <Expandable title="verification properties">
        <ResponseField name="verified" type="boolean">
          Whether attestation is verified
        </ResponseField>

        <ResponseField name="verificationMethod" type="string">
          Method used for verification
        </ResponseField>

        <ResponseField name="verificationTimestamp" type="string">
          ISO 8601 timestamp of verification
        </ResponseField>

        <ResponseField name="trustScore" type="number">
          Trust score of the attestation
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="pagination" type="object">
  Pagination information

  <Expandable title="pagination properties">
    <ResponseField name="total" type="number">
      Total number of attestations
    </ResponseField>

    <ResponseField name="limit" type="number">
      Number of attestations returned
    </ResponseField>

    <ResponseField name="offset" type="number">
      Current offset
    </ResponseField>

    <ResponseField name="hasMore" type="boolean">
      Whether more attestations are available
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="summary" type="object">
  Attestation summary statistics

  <Expandable title="summary properties">
    <ResponseField name="totalAttestations" type="number">
      Total number of attestations
    </ResponseField>

    <ResponseField name="activeAttestations" type="number">
      Number of active attestations
    </ResponseField>

    <ResponseField name="expiredAttestations" type="number">
      Number of expired attestations
    </ResponseField>

    <ResponseField name="revokedAttestations" type="number">
      Number of revoked attestations
    </ResponseField>

    <ResponseField name="schemaBreakdown" type="object">
      Breakdown by schema type
    </ResponseField>

    <ResponseField name="categoryBreakdown" type="object">
      Breakdown by category
    </ResponseField>

    <ResponseField name="averageTrustScore" type="number">
      Average trust score across all attestations
    </ResponseField>

    <ResponseField name="verifiedCount" type="number">
      Number of verified attestations
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="timestamp" type="string">
  ISO 8601 timestamp of the response
</ResponseField>

## Examples

<CodeGroup>
  ```bash cURL (All Attestations) theme={null}
  curl "https://api.onzks.com/v1/trust/attestations/alice.zks" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```bash cURL (Skill Attestations Only) theme={null}
  curl "https://api.onzks.com/v1/trust/attestations/alice.zks?schema=skill&status=active" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```bash cURL (Public Attestations) theme={null}
  curl "https://api.onzks.com/v1/trust/attestations/alice.zks?public=true&limit=20" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```bash cURL (Wallet Address) theme={null}
  curl "https://api.onzks.com/v1/trust/attestations/0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  async function getAttestations(identity, options = {}) {
    const {
      schema,
      issuer,
      status = 'active',
      category,
      tags,
      public: isPublic,
      limit = 50,
      offset = 0,
      sortBy = 'createdAt',
      sortOrder = 'desc',
      includeMetadata = true,
      includeEvidence = true
    } = options;

    const params = new URLSearchParams({
      status,
      limit: limit.toString(),
      offset: offset.toString(),
      sortBy,
      sortOrder,
      includeMetadata: includeMetadata.toString(),
      includeEvidence: includeEvidence.toString()
    });

    if (schema) params.append('schema', schema);
    if (issuer) params.append('issuer', issuer);
    if (category) params.append('category', category);
    if (tags) params.append('tags', tags);
    if (isPublic !== null) params.append('public', isPublic.toString());

    const response = await fetch(
      `https://api.onzks.com/v1/trust/attestations/${identity}?${params}`,
      {
        headers: {
          'Authorization': 'Bearer YOUR_API_KEY'
        }
      }
    );

    const data = await response.json();

    console.log(`Attestations for ${data.zksId || data.address}:`);
    console.log(`Total: ${data.summary.totalAttestations}`);
    console.log(`Active: ${data.summary.activeAttestations}`);
    console.log(`Verified: ${data.summary.verifiedCount}`);
    console.log(`Average Trust Score: ${data.summary.averageTrustScore}`);

    return data;
  }

  // Usage examples
  await getAttestations('alice.zks');
  await getAttestations('alice.zks', { schema: 'skill', status: 'active' });
  await getAttestations('alice.zks', { public: true, limit: 20 });
  await getAttestations('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb');
  ```

  ```python Python theme={null}
  import requests

  def get_attestations(identity, schema=None, issuer=None, status='active', category=None,
                      tags=None, public=None, limit=50, offset=0, sort_by='createdAt',
                      sort_order='desc', include_metadata=True, include_evidence=True):
      params = {
          'status': status,
          'limit': limit,
          'offset': offset,
          'sortBy': sort_by,
          'sortOrder': sort_order,
          'includeMetadata': include_metadata,
          'includeEvidence': include_evidence
      }
      
      if schema:
          params['schema'] = schema
      if issuer:
          params['issuer'] = issuer
      if category:
          params['category'] = category
      if tags:
          params['tags'] = tags
      if public is not None:
          params['public'] = public
      
      response = requests.get(
          f'https://api.onzks.com/v1/trust/attestations/{identity}',
          headers={'Authorization': 'Bearer YOUR_API_KEY'},
          params=params
      )
      
      data = response.json()
      
      print(f"Attestations for {data.get('zksId', data['address'])}:")
      print(f"Total: {data['summary']['totalAttestations']}")
      print(f"Active: {data['summary']['activeAttestations']}")
      print(f"Verified: {data['summary']['verifiedCount']}")
      print(f"Average Trust Score: {data['summary']['averageTrustScore']}")
      
      return data

  # Usage examples
  get_attestations('alice.zks')
  get_attestations('alice.zks', schema='skill', status='active')
  get_attestations('alice.zks', public=True, limit=20)
  get_attestations('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb')
  ```
</CodeGroup>

## Response Example

```json theme={null}
{
  "success": true,
  "address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
  "zksId": "alice.zks",
  "attestations": [
    {
      "id": "att_1234567890abcdef",
      "subject": "alice.zks",
      "issuer": "0x9876543210fedcba...",
      "schema": "skill",
      "data": {
        "title": "Solidity Developer",
        "description": "Expert in smart contract development",
        "category": "programming",
        "value": "expert",
        "metadata": {
          "yearsExperience": 5,
          "projects": ["DeFi Protocol", "NFT Marketplace"],
          "certifications": ["Certified Solidity Developer"]
        },
        "evidence": [
          {
            "type": "url",
            "value": "https://github.com/alice/solidity-projects",
            "description": "GitHub repository with Solidity projects"
          }
        ]
      },
      "signature": "0xabcdef1234567890...",
      "createdAt": "2024-01-15T10:30:00Z",
      "expiry": "2025-01-15T10:30:00Z",
      "revocable": true,
      "public": true,
      "status": "active",
      "tags": ["solidity", "blockchain", "developer"],
      "verification": {
        "verified": true,
        "verificationMethod": "signature_verification",
        "verificationTimestamp": "2024-01-15T10:30:00Z",
        "trustScore": 85.5
      }
    },
    {
      "id": "att_abcdef1234567890",
      "subject": "alice.zks",
      "issuer": "0x1234567890abcdef...",
      "schema": "relationship",
      "data": {
        "title": "Business Partner",
        "description": "Long-term business partnership",
        "category": "business",
        "value": "trusted",
        "metadata": {
          "relationshipType": "business_partner",
          "duration": "3 years",
          "projects": ["Joint Venture", "Consulting"]
        },
        "evidence": [
          {
            "type": "transaction",
            "value": "0x1234567890abcdef...",
            "description": "Business transaction history"
          }
        ]
      },
      "signature": "0x1234567890abcdef...",
      "createdAt": "2024-01-10T14:20:00Z",
      "expiry": null,
      "revocable": true,
      "public": true,
      "status": "active",
      "tags": ["business", "partnership", "trusted"],
      "verification": {
        "verified": true,
        "verificationMethod": "signature_verification",
        "verificationTimestamp": "2024-01-10T14:20:00Z",
        "trustScore": 92.3
      }
    }
  ],
  "pagination": {
    "total": 15,
    "limit": 50,
    "offset": 0,
    "hasMore": false
  },
  "summary": {
    "totalAttestations": 15,
    "activeAttestations": 12,
    "expiredAttestations": 2,
    "revokedAttestations": 1,
    "schemaBreakdown": {
      "skill": 8,
      "relationship": 4,
      "achievement": 2,
      "reputation": 1
    },
    "categoryBreakdown": {
      "programming": 5,
      "business": 4,
      "blockchain": 3,
      "leadership": 2,
      "education": 1
    },
    "averageTrustScore": 78.5,
    "verifiedCount": 14
  },
  "timestamp": "2024-01-20T15:45:00Z"
}
```

## Use Cases

### 1. Reputation Profile

Create a comprehensive reputation profile:

```javascript theme={null}
function createReputationProfile(attestations) {
  const profile = {
    skills: attestations.filter(a => a.schema === 'skill'),
    relationships: attestations.filter(a => a.schema === 'relationship'),
    achievements: attestations.filter(a => a.schema === 'achievement'),
    reputation: attestations.filter(a => a.schema === 'reputation'),
    identity: attestations.filter(a => a.schema === 'identity')
  };

  return {
    ...profile,
    summary: {
      totalSkills: profile.skills.length,
      totalRelationships: profile.relationships.length,
      totalAchievements: profile.achievements.length,
      averageTrustScore: calculateAverageTrustScore(attestations),
      verifiedCount: attestations.filter(a => a.verification.verified).length
    }
  };
}
```

### 2. Skill Verification

Verify specific skills:

```javascript theme={null}
function verifySkills(attestations, requiredSkills) {
  const skillAttestations = attestations.filter(a => a.schema === 'skill');
  
  const verifiedSkills = requiredSkills.map(skill => {
    const attestation = skillAttestations.find(a => 
      a.data.title.toLowerCase().includes(skill.toLowerCase()) ||
      a.data.category === skill
    );
    
    return {
      skill,
      verified: !!attestation,
      attestation: attestation || null,
      trustScore: attestation?.verification.trustScore || 0
    };
  });
  
  return verifiedSkills;
}

// Usage
const requiredSkills = ['Solidity', 'React', 'Node.js'];
const skills = verifySkills(attestations, requiredSkills);
```

### 3. Trust Score Calculation

Calculate overall trust score:

```javascript theme={null}
function calculateTrustScore(attestations) {
  const activeAttestations = attestations.filter(a => a.status === 'active');
  
  if (activeAttestations.length === 0) {
    return 0;
  }
  
  const totalScore = activeAttestations.reduce((sum, attestation) => {
    return sum + attestation.verification.trustScore;
  }, 0);
  
  const averageScore = totalScore / activeAttestations.length;
  
  // Weight by schema type
  const weights = {
    skill: 1.0,
    relationship: 1.2,
    achievement: 1.1,
    reputation: 1.3,
    identity: 1.5
  };
  
  const weightedScore = activeAttestations.reduce((sum, attestation) => {
    const weight = weights[attestation.schema] || 1.0;
    return sum + (attestation.verification.trustScore * weight);
  }, 0);
  
  const totalWeight = activeAttestations.reduce((sum, attestation) => {
    return sum + (weights[attestation.schema] || 1.0);
  }, 0);
  
  return {
    averageScore,
    weightedScore: weightedScore / totalWeight,
    totalAttestations: activeAttestations.length,
    breakdown: groupBySchema(activeAttestations)
  };
}
```

### 4. Attestation Filtering

Filter attestations by various criteria:

```javascript theme={null}
function filterAttestations(attestations, filters) {
  return attestations.filter(attestation => {
    if (filters.schema && attestation.schema !== filters.schema) return false;
    if (filters.status && attestation.status !== filters.status) return false;
    if (filters.category && attestation.data.category !== filters.category) return false;
    if (filters.public !== null && attestation.public !== filters.public) return false;
    if (filters.verified && !attestation.verification.verified) return false;
    if (filters.minTrustScore && attestation.verification.trustScore < filters.minTrustScore) return false;
    if (filters.tags && !filters.tags.some(tag => attestation.tags.includes(tag))) return false;
    
    return true;
  });
}

// Usage
const filteredAttestations = filterAttestations(attestations, {
  schema: 'skill',
  status: 'active',
  verified: true,
  minTrustScore: 80,
  tags: ['blockchain', 'programming']
});
```

### 5. Attestation Analytics

Analyze attestation patterns:

```javascript theme={null}
function analyzeAttestations(attestations) {
  const analysis = {
    bySchema: groupBy(attestations, 'schema'),
    byCategory: groupBy(attestations, 'data.category'),
    byStatus: groupBy(attestations, 'status'),
    byIssuer: groupBy(attestations, 'issuer'),
    trustScoreDistribution: calculateTrustScoreDistribution(attestations),
    timeDistribution: calculateTimeDistribution(attestations),
    evidenceTypes: analyzeEvidenceTypes(attestations)
  };
  
  return analysis;
}

function groupBy(array, key) {
  return array.reduce((groups, item) => {
    const value = item[key];
    if (!groups[value]) {
      groups[value] = [];
    }
    groups[value].push(item);
    return groups;
  }, {});
}
```

## Best Practices

### 1. Caching

Cache attestation data for performance:

```javascript theme={null}
let attestationCache = new Map();
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes

async function getCachedAttestations(identity, options = {}) {
  const cacheKey = `${identity}-${JSON.stringify(options)}`;
  const cached = attestationCache.get(cacheKey);
  
  if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
    return cached.data;
  }
  
  const data = await getAttestations(identity, options);
  attestationCache.set(cacheKey, {
    data,
    timestamp: Date.now()
  });
  
  return data;
}
```

### 2. Pagination

Handle large attestation collections:

```javascript theme={null}
async function getAllAttestations(identity, options = {}) {
  const allAttestations = [];
  let offset = 0;
  const limit = 100;
  
  while (true) {
    const data = await getAttestations(identity, {
      ...options,
      limit,
      offset
    });
    
    allAttestations.push(...data.attestations);
    
    if (!data.pagination.hasMore) {
      break;
    }
    
    offset += limit;
  }
  
  return allAttestations;
}
```

### 3. Real-time Updates

Subscribe to attestation updates:

```javascript theme={null}
function subscribeToAttestationUpdates(identity, callback) {
  const ws = new WebSocket(`wss://api.onzks.com/v1/trust/attestations/${identity}/subscribe`);
  
  ws.onmessage = (event) => {
    const update = JSON.parse(event.data);
    callback(update);
  };
  
  return () => ws.close();
}
```

### 4. Verification

Verify attestation authenticity:

```javascript theme={null}
async function verifyAttestation(attestation) {
  const message = JSON.stringify({
    subject: attestation.subject,
    schema: attestation.schema,
    data: attestation.data,
    createdAt: attestation.createdAt
  });
  
  const recoveredAddress = await recoverAddress(message, attestation.signature);
  const isValid = recoveredAddress === attestation.issuer;
  
  return {
    valid: isValid,
    issuer: attestation.issuer,
    recoveredAddress,
    message
  };
}
```

## Related Endpoints

* [Create Attestation](/api-reference/trust-layer/create-attestation) - Create new attestations
* [Revoke Attestation](/api-reference/trust-layer/revoke-attestation) - Revoke attestations
* [Evaluate Policy](/api-reference/trust-layer/evaluate-policy) - Evaluate trust policies
* [Get Modules](/api-reference/trust-layer/get-modules) - Get available trust modules

## Troubleshooting

### "No attestations found"

**Cause**: No attestations match the criteria or user has no attestations.

**Solution**:

* Remove restrictive filters
* Check if the user has any attestations
* Verify the identity is correct

### "Invalid schema filter"

**Cause**: Unsupported schema value.

**Solution**:

* Use supported schemas: skill, relationship, achievement, reputation, identity, custom
* Check for typos

### "Invalid status filter"

**Cause**: Unsupported status value.

**Solution**:

* Use supported statuses: active, expired, revoked, all
* Check for typos

## Rate Limits

Attestation requests are subject to rate limits:

* **Free tier**: 60 requests per minute
* **Starter tier**: 300 requests per minute
* **Professional tier**: 1,000 requests per minute
* **Enterprise tier**: Custom limits

Implement caching to reduce API calls.
