This page documents the Nutch 1.X REST API v1.0.
It provides details on the type of REST calls which can be made to the Nutch 1.x REST API. Many of the API points are adapted from the ones provided by the Nutch 2.x REST API. One of the reasons to come up with a REST API is to integrate D3 to show visualizations about the working of a Nutch crawl.
Follow the steps below to start an instance of the Nutch Server on localhost.
% cd runtime/local % ./bin/nutch startserver -port <port_number> \[If the port option is not mentioned then by default the server starts on port 8081\] |
The different API calls that can be made are listed below.
This API point is created in order to get server status and manage server's state.
GET /admin |
Response contains server startup date, availible configuration names, job history and currently running jobs.
{ "startDate":1424572500000, "configuration":[ "default" ], "jobs":[ ], "runningJobs":[ ] } |
It is possible to stop running server using /admin/stop.
GET /admin/stop |
Response
Stopping in server on port 8081 |
GET /config |
Response contains names of available configurations.
["default","custom-config"] |
GET /config/{configuration name} Examples: GET /config/default GET /config/custom-config |
Response contains parameters with values
{ "anchorIndexingFilter.deduplicate":"false", "crawl.gen.delay":"604800000", "db.fetch.interval.default":"2592000", "db.fetch.interval.max":"7776000", .... .... } |
Creates new Nutch configuration with given parameters.
POST /config/create Examples: POST /config/create { "configId":"new-config", "params":{"anchorIndexingFilter.deduplicate":"false",... } } # curl curl -X POST -H "Content-Type: application/json" http://localhost:8081/config/create -d '{"configId":"new-config", "params":{"anchorIndexingFilter.deduplicate":"false"}}' |
Response is created config's id.
new-config |
GET /config/{configuration name}/{property} Examples: GET /config/default/anchorIndexingFilter.deduplicate |
Response contains parameter's value as string
false |
{
PUT /config/{configuration name}/{property} Examples: PUT /config/default/http.agent.name |
Response contains parameter's value as string
NUTCH_SOLR |
DELETE /config/{configuration name} Examples: DELETE /config/new-config |
This point allows job management, including creation, job information and killing of a job. For a complete tutorial, please follow How to run Jobs using the REST service.
curl -X GET -H 'Content-Type: application/json' -i http://localhost:8081/job |
Response contains list of all jobs (running and history)
[ { "id":"job-id-5977", "type":"FETCH", "confId":"default", "args":null, "result":null, "state":"FINISHED", "msg":"", "crawlId":"crawl-01" } { "id":"job-id-5978", "type":"PARSE", "confId":"default", "args":null, "result":null, "state":"RUNNING", "msg":"", "crawlId":"crawl-01" } ] |
GET /job/job-id-5977 |
Response
{ "id":"job-id-5977", "type":"FETCH", "confId":"default", "args":null, "result":null, "state":"FINISHED", "msg":"", "crawlId":"crawl01" } |
POST /job/job-id-5977/stop |
Response
true |
GET /job/job-id-5977/abort |
}
Response
{
true |
}
Create job with given parameters. You should either specify Job Type(like INJECT, GENERATE, FETCH, PARSE, etc ) or jobClassName.
curl -X POST -H 'Content-Type: application/json' -i http://localhost:8081/job/create --data '{"crawlId":"crawl01", "type":"INJECT", "confId":"default", "args": {"url_dir":"seedFiles/seed-1641959745623", "crawldb": "crawldb"}}' |
Response object is provided below
{ "id": "crawl01-default-INJECT-1877363907", "type": "INJECT", "confId": "default", "args": { "url_dir": "seedFiles/seed-1641959745623", "crawldb": "crawldb" }, "result": null, "state": "RUNNING", "msg": "OK", "crawlId": "crawl01" } |
The /seed/create endpoint enables the user to create a seedlist and return the temporary path of the file created. This path should be passed to the url_dir parameter of the INJECT job. It's also worth noting that the seed
curl -X POST -H 'Content-Type: application/json' -i http://localhost:8081/seed/create --data '{"name":"test","seedUrls":["https://nutch.apache.org"]}' |
Response is the relative file directory path. Note, this is relative to where the Nutch server was started. It's also worth noting that any seed lists which are created are persistent. That is to say they remain on disk even when nutch server is not running.
seedFiles/seed-1641959745623 |
The /seed endpoint facilitates retrieval of any seedlists which were created during the current server runtime.
As of Nutch 1.18 seed lists generated by previous server runtime sessions will not be available if the server is shutdown and restarted.
This point provides access to information stored in the CrawlDb.
POST /db/crawldb with following { "type":"stats", "confId":"default", "crawlId":"crawl01", "args":{"someParam":"someValue"} } |
The different values for the type parameter are - dump, topN and url. Their corresponding arguments can be found here.
Response contains information from the CrawlDbReader.java class. For the above mentioned request, the JSON response would like like-
{ "retry 0":"8350", "minScore":"0.0", "retry 1":"96", "status":{ "3":{"count":"21","statusValue":"db_gone"}, "2":{"count":"594","statusValue":"db_fetched"}, "1":{"count":"7721","statusValue":"db_unfetched"}, "5":{"count":"86","statusValue":"db_redir_perm"}, "4":{"count":"24","statusValue":"db_redir_temp"} }, "totalUrls":"8446", "maxScore":"0.528", "avgScore":"0.029593771" } |
Note: If any other type than stats (like dump, topN, url) is used then the response will be a file (application-octet-stream).
Description of more API points coming soon.