Encode files or textual data using base64 encoding algorithm - REST API Reference
You can encode text or files as as base64 encoded strings using REST API. In this section we will describe each option to pass the files or text to our Base64 encoder.
Encode textual data to base64 string
To encode some textual data as base64 encoded string, please set the "content-type" header to "text/plain". An example request would look like this:
[HTTP POST] https://api.thebase64.com/encode?secret=your_secret Content-Type: text/plain This is some text to be encoded as base64 string
Request Payload
Your request body should contain plain text data that you want to encode.
Encode file accessible via URL using JSON
To encode a file accessible via URL, please set the "content-type" header to "application/json". An example request would look like this:
[HTTP POST] https://api.thebase64.com/encode?secret=your_secret Content-Type: application/json { "FileUrl": "https://sample.com/doc.pdf" }
Request Payload
FileUrl string
The file URL to be encoded
Base64 encode file using FormData
You can pass your file as "multipart/form-data". Simply put your file into the FormData's Files property and POST it to our encoding endpoint:
[HTTP POST] https://api.thebase64.com/encode?secret=your_secret Content-Type: multipart/form-data; boundary=----FpbVSjGhtld6EDEy ------7MA4YWxkTrZu0gW Content-Disposition: form-data; name="File"; filename="sample.pdf" PDF FILE ----FpbVSjGhtld6EDEy--
FormData Parameters
Files File
The file to be encoded
Encode a file using the application/octet-stream
The application/octet-stream MIME type is used for binary files transfer. It preserves the file contents, but requires to specify the file name including the type. For this case, Content disposition header must be provided with the file name. Example: Content-Disposition: inline; filename="sample.pdf"
[HTTP POST] https://api.thebase64.com/encode?secret=your_secret Content-Type: application/octet-stream Content-Disposition: inline; filename="sample.pdf" ---File Bytes---