POST ga4gh/references/search

Return a list of reference sequences in GA4GH format

Parameters

Required

NameTypeDescriptionDefaultExample Values
referenceSetId string Return references for a referenceSet - GRCh38

Optional

NameTypeDescriptionDefaultExample Values
accession string Return reference information for a specific accession - NC_000021.9
callback String Name of the callback subroutine to be returned by the requested JSONP response. Required ONLY when using JSONP as the serialisation method. Please see the user guide. - randomlygeneratedname
md5checksum string Return reference information for the md5checksum of the sequence - 9489ae7581e14efcad134f02afafe26c
pageSize Int Number of references to return per request 10 -
pageToken Int Identifier showing which page of data to retrieve next null -

Message

Content-typeFormatExample
application/json{ "referenceSetId": string, "md5checksum": string, "accession": string, "pageToken": string, "pageSize": Int }{ "referenceSetId": "GRCh38", "pageSize": 10 }

Example Requests

/ga4gh/references/search


{ "referenceSetId": "GRCh38", "pageSize": 10 }
        
  1. use strict;
  2. use warnings;
  3.  
  4. use HTTP::Tiny;
  5.  
  6. my $http = HTTP::Tiny->new();
  7.  
  8. my $server = 'https://jan2020.rest.ensembl.org';
  9. my $ext = '/ga4gh/references/search';
  10. my $response = $http->request('POST', $server.$ext, {
  11. headers => {
  12. 'Content-type' => 'application/json',
  13. 'Accept' => 'application/json'
  14. },
  15. content => '{ "referenceSetId": "GRCh38", "pageSize": 10 }'
  16. });
  17.  
  18. die "Failed!\n" unless $response->{success};
  19.  
  20.  
  21. use JSON;
  22. use Data::Dumper;
  23. if(length $response->{content}) {
  24. my $hash = decode_json($response->{content});
  25. local $Data::Dumper::Terse = 1;
  26. local $Data::Dumper::Indent = 1;
  27. print Dumper $hash;
  28. print "\n";
  29. }
  30.  
  1. import requests, sys
  2.  
  3. server = "https://jan2020.rest.ensembl.org"
  4. ext = "/ga4gh/references/search"
  5. headers={ "Content-Type" : "application/json", "Accept" : "application/json"}
  6. r = requests.post(server+ext, headers=headers, data='{ "referenceSetId": "GRCh38", "pageSize": 10 }')
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12. decoded = r.json()
  13. print repr(decoded)
  14.  
  1. import requests, sys
  2.  
  3. server = "https://jan2020.rest.ensembl.org"
  4. ext = "/ga4gh/references/search"
  5. headers={ "Content-Type" : "application/json", "Accept" : "application/json"}
  6. r = requests.post(server+ext, headers=headers, data='{ "referenceSetId": "GRCh38", "pageSize": 10 }')
  7.  
  8. if not r.ok:
  9. r.raise_for_status()
  10. sys.exit()
  11.  
  12. decoded = r.json()
  13. print(repr(decoded))
  14.  
  1. require 'net/http'
  2. require 'uri'
  3.  
  4. server='https://jan2020.rest.ensembl.org'
  5. path = '/ga4gh/references/search'
  6.  
  7. url = URI.parse(server)
  8. http = Net::HTTP.new(url.host, url.port)
  9.  
  10. request = Net::HTTP::Post.new(path, {'Content-Type' => 'application/json', 'Accept' => 'application/json'})
  11. request.body = '{ "referenceSetId": "GRCh38", "pageSize": 10 }'
  12.  
  13. response = http.request(request)
  14.  
  15. if response.code != "200"
  16. puts "Invalid response: #{response.code}"
  17. puts response.body
  18. exit
  19. end
  20.  
  21.  
  22. require 'rubygems'
  23. require 'json'
  24. require 'yaml'
  25.  
  26. result = JSON.parse(response.body)
  27. puts YAML::dump(result)
  28.  
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.net.HttpURLConnection;
  4. import java.io.BufferedReader;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9. import java.io.DataOutputStream;
  10.  
  11.  
  12. public class EnsemblRest {
  13.  
  14. public static void main(String[] args) throws Exception {
  15. String server = "https://jan2020.rest.ensembl.org";
  16. String ext = "/ga4gh/references/search";
  17. URL url = new URL(server + ext);
  18.  
  19. URLConnection connection = url.openConnection();
  20. HttpURLConnection httpConnection = (HttpURLConnection)connection;
  21. String postBody = "{ \"referenceSetId\": \"GRCh38\", \"pageSize\": 10 }";
  22. httpConnection.setRequestMethod("POST");
  23. httpConnection.setRequestProperty("Content-Type", "application/json");
  24. httpConnection.setRequestProperty("Accept", "application/json");
  25. httpConnection.setRequestProperty("Content-Length", Integer.toString(postBody.getBytes().length));
  26. httpConnection.setUseCaches(false);
  27. httpConnection.setDoInput(true);
  28. httpConnection.setDoOutput(true);
  29.  
  30. DataOutputStream wr = new DataOutputStream(httpConnection.getOutputStream());
  31. wr.writeBytes(postBody);
  32. wr.flush();
  33. wr.close();
  34.  
  35. InputStream response = connection.getInputStream();
  36. int responseCode = httpConnection.getResponseCode();
  37.  
  38. if(responseCode != 200) {
  39. throw new RuntimeException("Response code was not 200. Detected response was "+responseCode);
  40. }
  41.  
  42. String output;
  43. Reader reader = null;
  44. try {
  45. reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
  46. StringBuilder builder = new StringBuilder();
  47. char[] buffer = new char[8192];
  48. int read;
  49. while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
  50. builder.append(buffer, 0, read);
  51. }
  52. output = builder.toString();
  53. }
  54. finally {
  55. if (reader != null) try {
  56. reader.close();
  57. } catch (IOException logOrIgnore) {
  58. logOrIgnore.printStackTrace();
  59. }
  60. }
  61.  
  62. System.out.println(output);
  63. }
  64. }
  65.  
  1. library(httr)
  2. library(jsonlite)
  3. library(xml2)
  4.  
  5. server <- "https://jan2020.rest.ensembl.org"
  6. ext <- "/ga4gh/references/search"
  7. r <- POST(paste(server, ext, sep = ""), content_type("application/json"), accept("application/json"), body = '{ "referenceSetId": "GRCh38", "pageSize": 10 }')
  8.  
  9. stop_for_status(r)
  10.  
  11. # use this if you get a simple nested list back, otherwise inspect its structure
  12. # head(data.frame(t(sapply(content(r),c))))
  13. head(fromJSON(toJSON(content(r))))
  14.  
  1. curl 'https://jan2020.rest.ensembl.org/ga4gh/references/search' -H 'Content-type:application/json' \
  2. -H 'Accept:application/json' -X POST -d '{ "referenceSetId": "GRCh38", "pageSize": 10 }'
  3.  
  1. wget -q --header='Content-type:application/json' --header='Accept:application/json' \
  2. --post-data='{ "referenceSetId": "GRCh38", "pageSize": 10 }' \
  3. 'https://jan2020.rest.ensembl.org/ga4gh/references/search' -O -
  4.  

Resource Information

MethodsPOST
Response formatsjson
jsonp