CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API only returning 25 records - ***really URGENT***
Pages: 1 [2]

Author Topic: API only returning 25 records - ***really URGENT***  (Read 5509 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: API only returning 25 records - ***really URGENT***
December 12, 2011, 04:40:12 am
What version are you using ?

the api explorer is under /civicrm/api/explorer (check out on demo)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API only returning 25 records - ***really URGENT***
December 12, 2011, 11:55:05 am
So, the 3 formats currently around are

$params['rowCount'] = 400;
$params['option.limit'] = 400;
$params['options'] = array('limit' => 400);

One of those should work!

Note that groupContact may not return smart group contacts (I'd have to check status with ColemanW on that)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

trevorwood

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 4
  • CiviCRM version: 4.0.2
  • CMS version: Joomla 1.6
  • MySQL version: 5.0.51a
  • PHP version: 5.2.6-1+lenny8
Re: API only returning 25 records - ***really URGENT***
December 22, 2011, 02:47:59 am
Thanks for this. groupContact doesn't appear to return smartgroup contacts so I've written some custom code to get round the problem. I'll revisit it when time permits.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: API only returning 25 records - ***really URGENT***
December 23, 2011, 06:14:01 am

Quote from: trevorwood on December 22, 2011, 02:47:59 am
Thanks for this. groupContact doesn't appear to return smartgroup contacts so I've written some custom code to get round the problem. I'll revisit it when time permits.

It would be useful to get it in the API IMO. Can you share the code?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

trevorwood

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 4
  • CiviCRM version: 4.0.2
  • CMS version: Joomla 1.6
  • MySQL version: 5.0.51a
  • PHP version: 5.2.6-1+lenny8
Re: API only returning 25 records - ***really URGENT***
December 27, 2011, 02:20:49 am
As soon as things quieten down I intend to put up any useful code and documentation.

Basically it works like this. The smart group consists of contacts (individuals & organizations) that are members of a group and have a specific tag. I retrieve the members of the group and then check to see if the tag is set. Cluncky but it works

kengle3

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: API only returning 25 records - ***really URGENT***
January 01, 2012, 04:51:14 pm
Is there any way to make it iterate through all the Contacts? I'm running into this problem with get contacts, but I can't figure out a way to then pull 26-50, 51-75, 76-100, etc.

I need to iterate over roughly three thousand contacts and counting, but I can't find a way to make the API loop and pull the next group of contacts.

Is there a way to iterate over all my contacts without having to maintain my own API functions, or perform a query for each individual contact?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API only returning 25 records - ***really URGENT***
January 01, 2012, 05:13:01 pm
So, you have $rowCount & $offSet as parameters - you'd need your own loop though
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Yaco

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 4.4.3
  • CMS version: Wordpress
  • MySQL version: 5.5.35
  • PHP version: 5.4.4
Re: API only returning 25 records - ***really URGENT***
February 02, 2014, 07:09:03 am
Just for the record:

Using 4.4.3, it is possible to get all the records by simply setting "rowCount" to 0 (zero).

In my case, I do:

civicrm_api('Contact','Get',array('group' => array(4 => 1), 'version' =>3, 'rowCount' => 0 ))

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API only returning 25 records - ***really URGENT***
February 02, 2014, 12:20:32 pm
Hmm - that's good I think & good to know - I don't think there is a test on it to 'lock it in' though.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: API only returning 25 records - ***really URGENT***
February 20, 2014, 09:34:35 am
Eileen:
Quote
you have $rowCount & $offSet as parameters

I wasn't aware of $offSet. Is there a wiki page where that's documented, or to which I could add it?

Thanks!
- Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API only returning 25 records - ***really URGENT***
February 20, 2014, 11:54:16 am
It's here

http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API#UsingtheAPI-Options

We should add a test 'locking in' the behaviour of $options['limit'] = 0 & document it there - generally 'rowCount' is less preferred than $options['limit']
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API only returning 25 records - ***really URGENT***

This forum was archived on 2017-11-26.