CodeSwitch

Any language, any framework, always secure

Integrate authentication into your APIs effertlosely with just a few lines of code. We offer SDKs for various languages and frameworks, alongside an intuitive REST API with a public OpenAPI specification.

        
            const { result, error } = await verifyKey({
                apiId: 'api_123',
                key: 'xyz_123'
            })
            
            if (error) {
                // handle network error
            }
            
            if (!result.valid) {
                // reject unauthorized request
            }
            
            // handle request
        
      
        
            import os
import codeswitch

async def main() -> None:
    client = codeswitch.Client(api_key=os.environ["API_KEY"])
    await client.start()

    result = await client.keys.verify_key("prefix_abc123")

    if result.is_ok {
        print(data.valid);
    } else {
        print(result.unwrap_err());
    }
        
      
      
    use codeswitch::Client;

    async fn verify_key() {
        let api_key = 
        env::var("codeswitch_API_KEY").expect("Environment variable CODESWITCH_API_KEY 
        not found");
        let c = Client::new(&api_key);
        let req = VerifyKeyRequest::new("test_req", "api_458vdYdbwut5LWABzXZP3Z8jPVas");
    
        match c.verify_key(req).await {
            Wrapped::Ok(res) => println!("{{res:?}}"),
            Wrapped::Err(err) => eprintln!("{{err:?}}"),
        }
    }
      
    
    
        import (
    "fmt"
    codeswitch "github.com/WilfredAlmeida/codeswitch-go/features"
)

func main() {
    apiKey := "key_3ZZ7faJrkfv1YAfhfAcnKW74";
    response, err := codeswitch.KeyVerify(apiKey);
    if err != nil {
        fmt.Println("Error:", err);
        return;
    }

    if response.Valid {
        fmt.Println("Key is valid");
    } else {
        fmt.Println("Key is invalid");
    }
}
    
  
  
    --url https://api.codeswitch.dev/v1/keys.verifyKey \
    --header 'Content-Type: application/json' \
    --data '{
        "apiId": "api_1234",
        "key": "sk_1234",
    }'
  

    # returns
%{
    "valid" => true,
    "ownerId" => "chronak",
    "meta" => %{
        "hello" => "world"
    }
}


    import com.codeswitch.codeswitchsdk.dto.KeyVerifyRequest;
import com.codeswitch.codeswitchsdk.dto.KeyVerifyResponse;

@RestController
public class APIController {

    private static IKeyService keyService = new KeyService();

    @PostMapping("/verify")
    public KeyVerifyResponse verifyKey(
        @RequestBody KeyVerifyRequest keyVerifyRequest) {
        // Delegate the creation of the key to the KeyService from the SDK
        return keyService.verifyKey(keyVerifyRequest);
    }
}

oss/acc

Open-source

We believe strongly in the value of open source: our codebase and development process is available to learn from and contribute to.

GitPulse