uploadxDocs
Esc

    SDKs

    Client libraries for TypeScript, Go, Rust and Python, each wrapping the HTTP API. Not published yet.

    Preview. None of these libraries is published yet, and the examples show their planned interface. Until they ship, call the HTTP API directly: it is plain JSON over HTTPS, and works from any language.

    Every SDK reads the key from UPLOADX_API_KEY, checks it with GET /v1/me on startup, and runs only on servers: none of them will run in a browser, where it would expose your key.

    TypeScript

    Terminal
    npm install @uploadx/sdk
    TypeScript
    import { Uploadx } from "@uploadx/sdk";
    
    const uploadx = new Uploadx({ apiKey: process.env.UPLOADX_API_KEY });
    
    const file = await uploadx.files.upload({
      file: await readFile("./onboarding.mp4"),
      name: "onboarding.mp4",
    });
    
    const { url } = await uploadx.files.url(file.id);

    Go

    Terminal
    go get github.com/uploadx/uploadx-go
    Go
    client := uploadx.New(os.Getenv("UPLOADX_API_KEY"))
    
    f, _ := os.Open("onboarding.mp4")
    file, err := client.Files.Upload(ctx, f, "onboarding.mp4")
    if err != nil {
    	log.Fatal(err)
    }
    
    fmt.Println(file.URL)

    Rust

    Terminal
    cargo add uploadx
    Rust
    use std::{env, fs};
    use uploadx::Uploadx;
    
    let uploadx = Uploadx::new(env::var("UPLOADX_API_KEY")?);
    
    let file = uploadx
        .files()
        .upload("onboarding.mp4", fs::read("onboarding.mp4")?)
        .await?;
    
    println!("{}", file.url);

    Python

    Terminal
    pip install uploadx
    Python
    import os
    from uploadx import Uploadx
    
    uploadx = Uploadx(api_key=os.environ["UPLOADX_API_KEY"])
    
    with open("onboarding.mp4", "rb") as f:
        file = uploadx.files.upload(f, name="onboarding.mp4")
    
    print(file.url)

    Any other language

    Create the record with your key, then PUT the bytes to the uploadUrl it returns. See Upload a file for both requests.