{% call register_example('python', 'button_label') %} Python {% endcall %} {% call register_example('python', 'request_limit') %}
{% trans url='https://github.com/ckan/ckanapi/blob/master/README.md#remoteckan' -%} (using the ckanapi client library) {%- endtrans %}
from ckanapi import RemoteCKAN
rc = RemoteCKAN('{{ h.url_for('home.index', qualified=True) }}', apikey=API_TOKEN)
result = rc.action.datastore_search(
resource_id="{{ resource_id }}",
limit=5,
q="jones",
)
print(result['records'])
from ckanapi import RemoteCKAN
rc = RemoteCKAN('{{ h.url_for('home.index', qualified=True) }}', apikey=API_TOKEN)
result = rc.action.datastore_search(
resource_id="{{ resource_id }}",
filters={
"subject": ["watershed", "survey"],
"stage": "active",
},
)
print(result['records'])
{% endcall %}
{% call register_example('python', 'request_sql') %}
from ckanapi import RemoteCKAN
rc = RemoteCKAN('{{ h.url_for('home.index', qualified=True) }}', apikey=API_TOKEN)
result = rc.action.datastore_search_sql(
sql="""SELECT * from "{{resource_id}}" WHERE title LIKE 'jones'"""
)
print(result['records'])
{% endcall %}
{% block custom %}{% endblock %}