grobid icon indicating copy to clipboard operation
grobid copied to clipboard

how to call the api from my web app

Open Victor-Mwelwa opened this issue 2 years ago • 4 comments

how do i call an API, like what, or how do i write the API URL to call for the GROBID service so that it process my headerdocument send me back the Json file.

Victor-Mwelwa avatar Sep 01 '21 07:09 Victor-Mwelwa

Hello @Victor-Mwelwa !

The Grobid documentation answers all these question in details.

kermitt2 avatar Sep 01 '21 08:09 kermitt2

well i have read the documentation, but what i want is an example of how you can call for a service... for example if am working on a web app no my local machine and i have GROBID service running, how to i tell the grobid service all i want it to do for me....in an URL....example (localhost:8070/api/......what do i put there. ) if want it to process the headerInformation and send the out put to the web app in JSON format.. thanks.

Victor-Mwelwa avatar Sep 01 '21 09:09 Victor-Mwelwa

documentation of the Web API with examples: https://grobid.readthedocs.io/en/latest/Grobid-service/#grobid-web-services

3 reference client implementations: https://grobid.readthedocs.io/en/latest/Grobid-service/#clients-for-grobid-web-services

kermitt2 avatar Sep 01 '21 09:09 kermitt2

@Victor-Mwelwa I was recently working on GROBID and to use it more efficiently came up with this solution which can be used.

import requests

# GROBID_URL = 'http://localhost:8070' #if you wish to use service running in your local
GROBID_URL = 'https://cloud.science-miner.com/grobid/' 
url = '%s/api/processFulltextDocument' % GROBID_URL
xml = requests.post(url, files={'input': open(filename, 'rb')}).text

ManuSinghal97 avatar Feb 02 '22 17:02 ManuSinghal97