An open API service indexing awesome lists of open source software.

https://github.com/archetype-dynamics/ostrichdb-client-examples

Interact with the OstrichDB API layer using your favorite language!
https://github.com/archetype-dynamics/ostrichdb-client-examples

Last synced: 5 months ago
JSON representation

Interact with the OstrichDB API layer using your favorite language!

Awesome Lists containing this project

README

          

# OstrichDB API Client Examples

This directory contains example clients demonstrating how to interact with the OstrichDB API layer in various programming languages. These examples are meant to serve as references and starting points for building your own client implementations.

## Available Examples:

- [C Client](./src/c-client.c)
- [C++ Client](./src/cpp-client.cpp)
- [Python Client](./src/python-client.py)
- [Go Client](./src/go-client.go)
- [Java Client](./src/java-client.java)
- [JavaScript Client](./src/js-client.js)
- [PHP Client](./src/php-client.php)
- [Ruby Client](./src/ruby-client.rb)
- [Rust Client](./src/rust-client.rs)
- [Swift Client](./src/swift-client.sswift)

## Future Client Examples Written In:

- Dart
- Kotlin
- Haskell
- Odin
- Lua

## Prerequisites
Some current examples and possibly future examples require additional libraries or dependencies.
Please ensure that you have the proper dependencies installed for each example.

### Python
- [requests](https://pypi.org/project/requests/)

### JavaScript
No additional dependencies are required as it uses the built-in [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) API.

### Go
No additional dependencies are required as it uses the built-in [net/http](https://pkg.go.dev/net/http) package.

### Ruby
No additional dependencies are required as it uses the built-in [net/http](https://ruby-doc.org/stdlib-2.7.0/libdoc/net/http/rdoc/Net/HTTP.html) library.

### PHP
No additional dependencies are required as it uses the built-in [file_get_contents](https://www.php.net/manual/en/function.file-get-contents.php) function.

### Swift
No additional dependencies are required as it uses the built-in [URLSession](https://developer.apple.com/documentation/foundation/urlsession) API.

### C
- [libcurl](https://curl.se/libcurl/)

### C++
- [libcurl](https://curl.se/libcurl/)

### Rust
- [reqwest](https://docs.rs/reqwest/latest/reqwest/)

### Java
- [java.net.http](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/package-summary.html)

## Usage
1. Ensure the OstrichDB server is running. It runs on: `localhost:8042`
2. Choose the example in your preferred language.
3. If necessary, install the required dependencies.
4. If necessary, modify the examples code to match your specific use case.
5. Follow any instructions provided in the example.
6. Run the example client.

# Building Your Own Client
The above examples demonstrate the basic patterns for:
- Making HTTP requests to OstrichDB endpoints
- Handling responses and errors from the server
- Working with OstrichDB collections, clusters, and records

Key points to remember when building your own client:
- Use appropriate HTTP methods (GET, POST, PUT, DELETE, HEAD)
- Set content-type headers to "text/plain"
- Follow the URL pattern structure:
- Collections: `/c/{collection_name}`
- Clusters: `/c/{collection_name}/cl/{cluster_name}`
- Records: `/c/{collection_name}/cl/{cluster_name}/r/{record_name}` sometimes with query parameters