Demos Network Specifications
  • Introduction
    • What is Demos Network
    • Demos Network Architecture
  • FAQ
  • Cookbook
    • Project setup
      • Run the project (MacOS)
      • Run the project (Windows)
        • WSL 2 Setup on Windows (10 and 11 only)
        • Issue Troubleshooting
      • Run the project (Ubuntu)
  • SDK
    • Getting Started
    • WebSDK
      • Authentication
        • FIDO2 Passkeys
          • Under the Hood: FIDO2 Passkeys
      • NodeCalls
      • Transactions
        • Creating a transaction
        • Signing a transaction
        • Broadcasting a transaction
      • L2PS SDK
        • The l2ps module
        • Interacting with the L2PS
        • L2PS Messaging System
      • Instant Messaging
        • What is the Instant Messaging Protocol?
        • Architecture Overview
        • Encryption
        • Quickstart
        • Message Types
        • API Reference
        • FAQ
    • Cross Chain
      • General layout of the XM SDKs
      • EVM
      • BTC
      • Solana
      • MultiversX (EGLD)
      • NEAR
      • IBC
      • TON
      • XRPL
      • The XMScript
      • Identities
    • Demoswork
    • Cookbook
      • Demoswork
        • Creating work steps
        • Conditional Operation
        • Base Operation
        • Signing and broadcasting
      • Transactions
        • Crosschain Transaction
        • Native Transactions
      • SWAP
        • Crosschain SWAP
    • Web2
      • Quick Start
      • DAHR API Reference
        • Types
      • Making Requests
      • Identities
        • Twitter
        • GitHub
    • API Reference
    • Bridges
      • Rubic Bridge Test
    • Post Quantum Cryptography
  • Backend
    • Internal Mechanisms
      • Network Time Synchronization
      • Cross Context Identities
    • Global Change Registry
      • GCR Structure
      • How is GCR Synced?
    • Consensus Mechanism
      • Unparalleled Scalability
      • Decentralization in PoR-BFT
      • Enhanced Security
      • Comparative Advantage
      • Addressing Potential Criticisms
      • Conclusion
    • Communications Stack
    • L2PS (Subnet) Framework
      • How are L2PS transactions handled?
    • Miscellaneous
      • Browsing the Postgres DB via psql
    • Bridges
      • Rubic Bridge
    • Developers Testbed
      • Setting up the environment
      • Setting up the repository
      • Installing dependencies
      • Node Configuration
      • Running the node
  • Frontend
    • Demos Providers Discovery Mechanism
Powered by GitBook
On this page
  • HTTP Methods
  • Request Parameters
  • Response Types
  • Usage Examples
  1. SDK
  2. Web2
  3. DAHR API Reference

Types

HTTP Methods

The Web2 proxy supports standard HTTP methods through the EnumWeb2Methods enum:

enum EnumWeb2Methods {
    GET = "GET",
    POST = "POST",
    PUT = "PUT",
    DELETE = "DELETE",
    PATCH = "PATCH"
}

Request Parameters

When making requests through the proxy, use the IStartProxyParams interface to structure your request:

interface IStartProxyParams {
    url: string                        // Target URL
    method: EnumWeb2Methods            // HTTP method to use
    options?: {                        // Optional parameters
        headers?: OutgoingHttpHeaders  // Request headers
        payload?: any                  // Request body (for POST/PUT/PATCH)
        authorization?: string         // Authorization header
    }
}

Response Types

Basic Response

The IWeb2Attestation interface provides verification data for the request:

interface IWeb2Result {
    status: number                    // HTTP status code
    statusText: string                // Status message
    headers: Record<string, string>   // Response headers
    data: any                         // Response body
}

Complete Response

All proxy requests return an IAttestationWithResponse, which combines the HTTP response with its attestation:

interface IAttestationWithResponse extends IWeb2Attestation {
    web2Response: IWeb2Result  // The HTTP response
}

Usage Examples

Handling Responses

const response = await dahr.startProxy({
    url: "https://api.example.com/data",
    method: EnumWeb2Methods.GET
}) as IAttestationWithResponse

// Access HTTP response data
console.log(response.web2Response.status)   // 200
console.log(response.web2Response.data)     // Response body

// Access attestation data
console.log(response.hash)                  // Request hash
console.log(response.timestamp)             // Attestation time
console.log(response.valid)                 // Attestation validity

Type Checking

// Type guard for checking response type
function isAttestationResponse(response: any): response is IAttestationWithResponse {
    return 'web2Response' in response && 'hash' in response && 'valid' in response;
}
PreviousDAHR API ReferenceNextMaking Requests

Last updated 4 months ago