No description
Find a file
2022-04-13 20:35:28 -04:00
tests refactor library, fix issues, fix tests 2022-04-03 19:38:49 -04:00
tm_client refactor library, fix issues, fix tests 2022-04-03 19:38:49 -04:00
.gitignore restructure project and use private modules 2021-08-23 17:03:27 -04:00
LICENSE Initial commit 2021-05-19 21:46:34 +00:00
README.md update readme to reflect refactor 2022-04-03 21:33:48 -04:00
tm_client.nim fix MIME not being an argument in fetchMediaByTags 2022-04-13 20:35:28 -04:00
tm_client.nimble fix MIME not being an argument in fetchMediaByTags 2022-04-13 20:35:28 -04:00

nim-tm-client

Asychronous API client library for TwineMedia for Nim

Include in your project by importing "tm_client".

Examples

Authenticate with a token:

import tm_client
import asyncdispatch
import strformat

const root = "https://your.tm.instance"
const token = "YOUR_TOKEN_HERE"

proc main() {.async.} =
    # Create client
    let client = newClientFromToken(root, token)

    # Optionally fetch client account info
    let info = await client.fetchSelfAccountInfo()

    echo fmt"Account name is: {info.name}, and email is: {info.email}"

# Wait for async code
waitFor main()

Authenticate with email and password:

import tm_client
import asyncdispatch
import strformat

const root = "https://your.tm.instance"
const email = "me@example.com"
const password = "drowssap"

proc main() {.async.} =
    # Create client with credentials
    let client = await newClientFromCredentials(root, email, password)

    # Optionally fetch client account info
    let info = await client.fetchSelfAccountInfo()

    echo fmt"Account name is: {info.name}, and email is: {info.email}"

# Wait for async code
waitFor main()

Fetch first 3 uploaded files:

import tm_client
import tm_client/enum
import asyncdispatch
import strformat

# ...Client creation code, etc...

let media = await client.fetchMedia(limit = 3, order = MediaCreatedOnAsc)

for file in media:
    echo fmt"Name: {file.name}, size: {file.size}"