Quick and dirty
$endpoint = "http://localhost:41184"
$token = "xxxxxxxxxx"
Try
{
$uri = ($endpoint + "/ping")
if( (Invoke-WebRequest -Uri $uri).Content -ne "JoplinClipperServer")
{
Write-Host "No Joplin API endpoint" -ForegroundColor Red
exit
}
}
Catch
{
Write-Host "Message: [$($_.Exception.Message)"] -ForegroundColor Red
exit
}
Try
{
$page = 1
Do
{
$uri = ($endpoint + "/notes?token=" + $token + "&fields=id,title,body&page=" + $page)
$notes = (Invoke-WebRequest -Uri $uri).Content
$notes = $notes | ConvertFrom-Json
for ($i=0; $i -lt $notes.items.Count; $i++) {
$id = $notes.items[$i].id
$body = $notes.items[$i].body
$title = $notes.items[$i].title
$body | Out-File -FilePath ($title + ".md")
}
$page = $page +1
} While ( $notes.has_more -eq $True )
}
Catch
{
Write-Host "Message: [$($_.Exception.Message)"] -ForegroundColor Red
exit
}