JSON Search Results

Registered by Wayne Connolly on 2011-06-13

We would like the query results of http://www.openclipart.org/api/search/?query=christmas,elf,hat&page=1&results=40&format=json& to be available for each record to be integrated into out CMS.

The first JSON integer is the record number starting at zero and going until when the recordset ends (reset per batch).

Is it possible to only return X records at a time please?

{"msg" : "success",
  "info" : {"results: "1200",
                "pages" : "12",
                 "current_page" : "3"
  "payload" :[
                   "title" : "Santa Hat",

                    "uploader" : "TheresaKnott",
                    "drawn_by" : "/ TheresaKnott",
                    "description" : "A santa hat for christmas sutable for putting on other drawings.",
                    "tags" : "media , clip_art , public_domain , image , svg , santa , christmas , hat , santa , christmas , hat",
                    "downloaded_by" : "2324",
                    "rated_by" : "10",
                    "detail_link" : "http://www.openclipart.org/detail/889",
                    "created" : "2006-10-25 09:09:50",
                    "svg" : {"url" : "http://www.openclipart.org/people/TheresaKnott/TheresaKnott_Santa_Hat.svg",
                                "height" :"800",
                                "width" : "760"
                    "png_thumb" : {"url" : "http://www.openclipart.org/image/250px/svg_to_png/TheresaKnott_Santa_Hat.png",
                                "height" :"250", "
                                width" : "230"
                    "png_full_lossy" : {"url" : "http://www.openclipart.org/image/800px/svg_to_png/TheresaKnott_Santa_Hat.png",
                                "height" :"800",
                                "width" : "760"


Blueprint information

Brad Phillips
Series goal:
Milestone target:
milestone icon 3.1
Started by
rejon on 2011-06-13
Completed by
Brad Phillips on 2011-09-15

Related branches



11th May 2012

I second the need for the json to be valid, pasting any of the current output into http://jsonlint.com/ results in invalid json, this is causing the iPad app I'm developing to trip up when it comes to parsing the json data.



This is excellent - I will integrate our CMS search into this over the weekend but it looks pretty well perfect however one thing.

You have every image object nested beneath its own payload. This is wrong. The fix is that all objects should be beneath a single payload.

Ie. Each result set that is delivered to the user should only have a single payload.




Thanks for looking at, Wayne. How does it look now? - Brad 9-15-2011


Hi Brad,

This is great so far except for the obvious whitespace and line breaks.

And also each item nested beneath the payload is still not numbered. We can't access it directly if it has no number.

Should start at 0 and increment up.

--Wayne 17/07/2011

Hi, so I have taken a look at the blueprint example code & have been trying to come up with something that closely mirrors it. If you navigate to the following url, you can see what I'm talking about: http://www.openclipart.org/search/json/?query=christmas&page=1

Notice, you can change the search query or the page number & the results will be updated, upon reload.

A few things I'm having issues with: I'm unsure of where or how to pull the image size information into the info (I'm not sure it's stored in the db, but I may be wrong). I'll have a look to be sure. Also, the current page is stored in Aiki, but I'm unsure of how to pull it out into the information.

Can you take a look at what's happening here & make notes on things you'd like changed, or issues with the results, in their current state?

-- Brad 6/13/2011

This is very close I think.

The main issue i see is that

a) the page attempts to download rather than rendering as txt in the prowser(just a server config issue)
b) The results should appear under the payload incrementally. Like. (I wasnt very clear on this in the initial request - sorry).

  "payload" :[ {"title" : "christmas decoration",

                    "uploader" : "artokem",
                    "drawn_by" : "/ artokem",
                    "description" : "A decorative ribbon with a Christmas feel to it",
                    "tags" : "christmas decoration, x-mas decoration, decoration, ribbon",
                    "downloaded_by" : "113",
                    "rated_by" : "0",

                    "detail_link" : "http://www.openclipart.org/detail/140875",
                    "created" : "2011-05-27 21:39:52",
                    "svg" : {"url" : "http://www.openclipart.org/people/artokem/christmas_decoration.svg",
                                "height" :"",
                                "width" : ""
                    "png_thumb" : {"url" : "http://www.openclipart.org/image/250px/svg_to_png/christmas_decoration.png",
                                "height" :"", "
                                width" : ""
                    "png_full_lossy" : {"url" : "http://www.openclipart.org/image/800px/svg_to_png/christmas_decoration.png",
                                "height" :"",
                                "width" : ""
                {"title" : "Ale santa",

                    "uploader" : "alepando",
                    "drawn_by" : "/ Alepando",
                    "description" : "comic face with Santa Claus hat and curly hair. Ale called",
                    "tags" : "christmas, Comic, face, curly, head, hat, santa claus, papa noel, icon, avatar, bonnet,",
                    "downloaded_by" : "226",
                    "rated_by" :"0",

                    "detail_link" : "http://www.openclipart.org/detail/130201",
                    "created" : "2011-04-01 00:29:13",
                    "svg" : {"url" : "http://www.openclipart.org/people/alepando/carita-ale-santa.svg",
                                "height" :"",
                                "width" : ""
                    "png_thumb" : {"url" : "http://www.openclipart.org/image/250px/svg_to_png/carita-ale-santa.png",
                                "height" :"", "
                                width" : ""
                    "png_full_lossy" : {"url" : "http://www.openclipart.org/image/800px/svg_to_png/carita-ale-santa.png",
                                "height" :"",
                                "width" : ""

-- Wayne 14 June 2011

Hey guys, keep up the great work. I really want to build something great with this upcoming JSON Api. So I already started looking at your progress.

It turns out the usage of non-escaped (and non unicode) whitespace characters drive a lot of JSON decoders mad. So a great major step would be to generate a valid UTF8 JSON String.

See http://jsonlint.com for validation


Ok, so I finally had some free space to get this working! It's still in early stages, but I've written a custom php script, as Aiki has some shortcomings that keep this from being completely possible inside of it's framework.

try the following: http://www.openclipart.org/search/json/?query=piano&page=6

Notice the payload numbers are now successfully incrementing, not only through a single page, but through the results set, as a whole.

Thanks for the tip on validation Wayne, I'll mark a bug & note that url you gave.

Please use this & let me know what's correct & what's incorrect. One thing I'm not sure of is what do display, in the event of a search without any matches.

Anyhow, another step towards some deeper ocal functionality!! - Brad 9-15-2011

-- Faro 16 July 2011


Work Items

This blueprint contains Public information 
Everyone can see this information.