Hello everyone, I was wondering if anyone else is using Omnivore as their read it later app and if so whether they’ve managed to connect to the API. It’s a GraphQL API and the documentation is somewhat minimal at the moment.
There’s a basic Python module which I’ve got to work, but I just can’t get anything out of it using JavaScript requests.
I’d like to be able to pull out lists of saved articles, including highlights and notes. Omnivore is by far my favourite app of this kind (I’ve previously tried Pocket, Wallabag and Raindrop) but I like to be able to access my own data. I’d be really grateful if anyone has made it work and has some advice.
2 Likes
Hi moggy1972, did you manage to make the API work ? I’m trying by my side, but I don’t know yet the graphQL language.
No - I’ve just been using the python module instead. When I get a bit more time I’m going to have a look at GraphQL…
I get to make this script work, but I can not yet get a query on article where isArchived is false…
let credential = Credential.create('Omnivore', 'Bookmarks');
credential.addTextField('clientRequestId', 'Client request id');
credential.addPasswordField('token', 'Access Token');
credential.authorize();
let clientRequestId = credential.getValue('clientRequestId'),
token = credential.getValue('token'),
http = HTTP.create(),
response = http.request({
url:'https://api-prod.omnivore.app/api/graphql',
method:'POST',
headers:{
'Authorization':token
},
data:{
query:'mutation SaveUrl($input: SaveUrlInput!) { saveUrl(input: $input) { ... on SaveSuccess { url clientRequestId } ... on SaveError { errorCodes message } } }',
variables:{input:{clientRequestId, source:'api', url:'https://blog.omnivore.app/p/contributing-to-omnivore', labels:[{name:'technologie'}, {name:'science'}]}}
}
});
if (!response.success) {
alert( 'Test Omnivore. ' + response.statusCode + ' ' + response.error);
return;
}
alert(JSON.stringify(response.responseData));
I tried with this query to get articles in Inbox, but I have error 400. I’m stuck here !
query { articles(where: {isArchived: false}) { id title } }
Thanks to the very responsive Omnivore team, the query is working with this script:
let credential = Credential.create('Omnivore', 'Bookmarks');
credential.addTextField('clientRequestId', 'Client request id');
credential.addPasswordField('token', 'Access Token');
credential.authorize();
let clientRequestId = credential.getValue('clientRequestId'),
token = credential.getValue('token'),
http = HTTP.create(),
response = http.request({
url:'https://api-prod.omnivore.app/api/graphql',
method:'POST',
headers:{
'Authorization':token,
'Content-Type':'application/json'
},
data:{
variables: {
after: undefined,
first: 50,
format: 'markdown',
includeContent: false,
query: 'in:inbox',
},
query: `query Search(
$after: String
$first: Int
$query: String
$includeContent: Boolean
$format: String
) {
search(
after: $after
first: $first
query: $query
includeContent: $includeContent
format: $format
) {
... on SearchSuccess {
edges {
node {
id
title
}
}
pageInfo {
hasNextPage
endCursor
totalCount
}
}
... on SearchError {
errorCodes
}
}
}`
}
})
let results = [];
if (response.statusCode == 200) {
let articles = response.responseData.data.search.edges;
articles.forEach(edge => {
results.push(`ID: ${edge.node.id}, Title: ${edge.node.title}`);
});
} else {
results.push(`Error: ${response.statusCode}`);
}
alert(JSON.stringify(results));
1 Like
That’s great - works for me. Thank you for finding that.
1 Like
Now I’m trying to write a query in order to archive all Inbox articles. Stay tuned
Here’s the code to bulk archive articles:
data:{
variables: {
query: 'in:inbox',
'action': 'ARCHIVE',
expectedCount: 50
},
query: `mutation BulkAction(
$query: String!
$action: BulkActionType!
$expectedCount: Int
) {
bulkAction(
query: $query
action: $action
expectedCount: $expectedCount
) {
... on BulkActionSuccess {
success
}
... on BulkActionError {
errorCodes
}
}
}`
}
}
Beware in variables, it’s important to quote ‘action’.