Projects¶
Find projects visible to the configured credential. Use Authentication.Anonymous() in the setup below to browse public projects without a token.
Setup¶
These snippets share this client. Replace the URL and token with your DataHub details. The complete sample files use offline responses when run by the documentation checks.
#r "nuget: DataHubClient"
open DataHubClient
let client =
DataHubClient("https://hub.example", Authentication.PersonalAccessToken("your-datahub-pat"))
import { DataHubClient } from "@nfdi4plants/datahub-client";
import { Authentication } from "@nfdi4plants/datahub-client/Http/Authentication.js";
const client = new DataHubClient(
"https://hub.example", Authentication.PersonalAccessToken("your-datahub-pat"));
import asyncio
from datahub_client import DataHubClient, Authentication
client = DataHubClient(
"https://hub.example", Authentication.PersonalAccessToken("your-datahub-pat"))
ListAsync¶
Get one page of projects. Both search and simple are optional; omit them to use the server defaults.
let projects =
client.Projects.ListAsync(search = "plant arc", simple = true) |> Async.RunSynchronously
for project in projects do printfn "%d: %s" project.Id project.PathWithNamespace
const projects = await client.Projects.ListAsync("plant arc", true);
for (const project of projects) console.log(project.Id, project.PathWithNamespace);
async def list_example():
projects = await client.Projects.ListAsync(search="plant arc", simple=True)
for project in projects:
print(project.Id, project.PathWithNamespace)
asyncio.run(list_example())
ListAllAsync¶
Get every matching project in ascending ID order. Optional visibility accepts public, internal, or private. Pages are requested until an empty page; invalid ordering or a failed page raises an error without returning partial results.
let allProjects =
client.Projects.ListAllAsync(visibility = "public") |> Async.RunSynchronously
printfn "Found %d public projects" allProjects.Count
const allProjects = await client.Projects.ListAllAsync(undefined, undefined, "public");
console.log(`Found ${allProjects.length} public projects`);
async def list_all_example():
all_projects = await client.Projects.ListAllAsync(visibility="public")
print(f"Found {len(all_projects)} public projects")
asyncio.run(list_all_example())
GetAsync¶
Get one project by numeric ID.
let project =
client.Projects.GetAsync(42) |> Async.RunSynchronously
printfn "%s: %s" project.Name project.WebUrl
const project = await client.Projects.GetAsync(42);
console.log(project.Name, project.WebUrl);
async def get_example():
project = await client.Projects.GetAsync(42)
print(project.Name, project.WebUrl)
asyncio.run(get_example())
SearchAsync¶
Search by name with the one-page convenience method. Use ListAllAsync(search = ...) in F#, ListAllAsync("plant arc") in JavaScript or TypeScript, or ListAllAsync(search=...) in Python when every page is needed.
let matches =
client.Projects.SearchAsync("plant arc") |> Async.RunSynchronously
for project in matches do printfn "%s" project.PathWithNamespace
const matches = await client.Projects.SearchAsync("plant arc");
for (const project of matches) console.log(project.PathWithNamespace);
async def search_example():
matches = await client.Projects.SearchAsync("plant arc")
for project in matches:
print(project.PathWithNamespace)
asyncio.run(search_example())