The OpenRefine Python Client Library from PaulMakepeace provides an interface to communicating with an OpenRefine server. This fork extends the command line interface (CLI) and supports communication between docker containers.
Switch branches/tags
Clone or download
Pull request Compare This branch is 44 commits ahead of PaulMakepeace:master.
Latest commit fd8f34b Dec 11, 2017


OpenRefine Python Client Library

The OpenRefine Python Client Library provides an interface to communicating with an OpenRefine server.



For native Python installation on Windows, Mac or Linux see Installation below.


Command line interface:

  • list all projects: python --list
  • create project from file: python --create [FILE]
  • apply rules from json file: python --apply [FILE.json] [PROJECTID/PROJECTNAME]
  • export project to file: python --export [PROJECTID/PROJECTNAME] --output=FILE.tsv
  • templating export: python --export "My Address Book" --template='{ "friend" : {{jsonize(cells["friend"].value)}}, "address" : {{jsonize(cells["address"].value)}} }' --prefix='{ "address" : [' --rowSeparator ',' --suffix '] }' --filterQuery="^mary$"
  • show project metadata: python --info [PROJECTID/PROJECTNAME]
  • delete project: python --delete [PROJECTID/PROJECTNAME]
  • check python --help for further options...

If you are familiar with python you may try all functions interactively (python -i or use this library in your own python scripts. Some Examples:

  • show version of OpenRefine server: refine.RefineServer().get_version()
  • show total rows of project 2151545447855: refine.RefineProject(refine.RefineServer(),'2151545447855').do_json('get-rows')['total']
  • compute clusters of project 2151545447855 and column key: refine.RefineProject(refine.RefineServer(),'2151545447855').compute_clusters('key')


Currently, the following API is supported:

  • project creation/import, deletion, export
  • facet computation
    • text
    • text filter
    • numeric
    • blank
    • starred & flagged
    • ... extensible class
  • 'engine': managing multiple facets and their computation results
  • sorting & reordering
  • clustering
  • transforms
  • transposes
  • single and mass edits
  • annotation (star/flag)
  • column
    • move
    • add
    • split
    • rename
    • reorder
    • remove
  • reconciliation
    • reconciliation judgment facet
    • guessing column type
    • querying reconciliation services preferences
    • perform reconciliation


By default the OpenRefine server URL is The environment variables OPENREFINE_HOST and OPENREFINE_PORT enable overriding the host & port.

In order to run all tests, a live Refine server is needed. No existing projects are affected.


(Someone with more familiarity with python's byzantine collection of installation frameworks is very welcome to improve/"best practice" all this.)

  1. Install dependencies, which currently is urllib2_file:

    sudo pip install -r requirements.txt

    (If you don't have pip visit

  2. Ensure you have a Refine server running somewhere and, if necessary, set the environment vars as above.

  3. Run tests, build, and install:

    python test # to do a subset, e.g., --test-suite tests.test_facet

    python build

    python install

There is a Makefile that will do this too, and more.


The API so far has been filled out from building a test suite to carry out the actions in David Huynh's Refine tutorial which while certainly showing off a wide range of Refine features doesn't cover the entire suite. Notable exceptions currently include:

  • reconciliation support is useful but not complete
  • undo/redo
  • Freebase
  • join columns
  • columns from URL


Pull requests with passing tests welcome! Source is at

Useful Tools

One aspect of development is watching HTTP transactions. To that end, I found Fiddler on Windows and HTTPScoop invaluable. The latter won't URL-decode nor nicely format JSON but the Online JavaScript Beautifier will.

Executables may be built with pyinstaller.


OpenRefine used to be called Google Refine, and this library used to be called the Google Refine Python Client Library.


Paul Makepeace, author, <>

David Huynh, initial cut

Artfinder, inspiration

Some data used in the test suite has been used from publicly available sources,