このコンテンツは選択した言語では利用できません。

Chapter 344. Yahoo Query Language Component


Available as of Camel version 2.21

The yql component is used for accessing the Yahoo Query Language platform.

The YQL (Yahoo! Query Language) platform enables you to query, filter, and combine data across the web through a single interface. It exposes a SQL-like syntax that is both familiar to developers and expressive enough for getting the right data.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-yql</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
Copy to Clipboard Toggle word wrap

344.1. URI format

yql://query[?options]
Copy to Clipboard Toggle word wrap

Where query represents the YQL query.

344.2. Options

The Yahoo Query Language component supports 2 options which are listed below.

Expand
NameDescriptionDefaultType

connectionManager (producer)

To use a custom configured HttpClientConnectionManager.

 

HttpClientConnection Manager

resolveProperty Placeholders (advanced)

Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders.

true

boolean

The Yahoo Query Language endpoint is configured using URI syntax:

yql:query
Copy to Clipboard Toggle word wrap

with the following path and query parameters:

344.2.1. Path Parameters (1 parameters):

Expand
NameDescriptionDefaultType

query

Required The YQL statement to execute.

 

String

344.2.2. Query Parameters (10 parameters):

Expand
NameDescriptionDefaultType

callback (producer)

The name of the JavaScript callback function for JSONP format. If callback is set and if format=json, then the response format is JSON. For more information on using XML instead of JSON, see JSONP-X. https://developer.yahoo.com/yql/guide/response.html

 

String

crossProduct (producer)

When given the value optimized, the projected fields in SELECT statements that may be returned in separate item elements in the response are optimized to be in a single item element instead. The only allowed value is optimized. More information https://developer.yahoo.com/yql/guide/response.htmlresponse-optimizing=

 

String

debug (producer)

If true, and if diagnostic is set to true, debug data is returned with the response. More information: https://developer.yahoo.com/yql/guide/dev-external_tables.htmlodt-enable-logging=

false

boolean

diagnostics (producer)

If true, diagnostic information is returned with the response.

false

boolean

env (producer)

Allows you to use multiple Open Data Tables through a YQL environment file. More information https://developer.yahoo.com/yql/guide/yql_storage.htmlusing-records-env-files=

 

String

format (producer)

The expected format. Allowed values: xml or json.

json

String

jsonCompat (producer)

Enables lossless JSON processing. The only allowed value is new. More information https://developer.yahoo.com/yql/guide/response.htmljson-to-json

 

String

throwExceptionOnFailure (producer)

Option to disable throwing the YqlHttpException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.

true

boolean

synchronous (advanced)

Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported).

false

boolean

https (security)

Option to use HTTPS to communicate with YQL.

true

boolean

344.3. Exchange data format

Camel will deliver the body as a JSON or XML formatted java.lang.String (see the format option above).

344.4. Message Headers

Expand
HeaderDescription

CamelYqlHttpRequest

Original HTTP request sent to YQL.

CamelYqlHttpStatus

Status code from the response.

344.5. Samples

344.5.1. Sample 1

In this example we query YQL to obtain the current wind and atmosphere data in Chicago:

from("direct:start")
  .to("yql://select wind, atmosphere from weather.forecast where woeid in (select woeid from geo.places(1) where text='chicago, il'");
Copy to Clipboard Toggle word wrap

Which will setup the body as:

{
   "query":{
      "count":1,
      "created":"2017-11-01T19:37:26Z",
      "lang":"en-US",
      "results":{
         "channel":{
            "wind":{
               "chill":"32",
               "direction":"165",
               "speed":"22"
            },
            "atmosphere":{
               "humidity":"71",
               "pressure":"994.0",
               "rising":"0",
               "visibility":"16.1"
            }
         }
      }
   }
}
Copy to Clipboard Toggle word wrap

and the headers:

344.5.2. Sample 2

In this example we query YQL to obtain the Google quote.

from("direct:start")
  .to("yql://select symbol, Ask, Bid, AverageDailyVolume from yahoo.finance.quotes where symbol in ('GOOG')?env=store://datatables.org/alltableswithkeys&https=false&callback=yqlCallback");
Copy to Clipboard Toggle word wrap

Which will setup the body as:

/**/yqlCallback({
   "query":{
      "count":1,
      "created":"2017-11-01T19:48:17Z",
      "lang":"en-US",
      "results":{
         "quote":{
            "symbol":"GOOG",
            "Bid":"1025.57",
            "Ask":"1025.92",
            "AverageDailyVolume":"1350640"AverageDailyVolume
         }
      }
   }
});
Copy to Clipboard Toggle word wrap

and the headers:

344.5.3. Sample 3

In this example we query YQL to obtain one book written by Barack Obama

from("direct:start")
  .to("yql://select * from google.books where q='barack obama' and maxResults=1?format=xml&crossProduct=optimized&env=store://datatables.org/alltableswithkeys");
Copy to Clipboard Toggle word wrap

Which will setup the body as:

<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1" yahoo:created="2017-11-01T20:32:22Z" yahoo:lang="en-US">
   <results>
      <json>
         <kind>books#volumes</kind>
         <totalItems>1993</totalItems>
         <items>
            <kind>books#volume</kind>
            <id>HRCHJp-V0QUC</id>
            <etag>SeTJeSgFDzo</etag>
            <selfLink>https://www.googleapis.com/books/v1/volumes/HRCHJp-V0QUC</selfLink>
            <volumeInfo>
               <title>Dreams from My Father</title>
               <subtitle>A Story of Race and Inheritance</subtitle>
               <authors>Barack Obama</authors>
               <publisher>Broadway Books</publisher>
               <publishedDate>2007-01-09</publishedDate>
               ...
            </volumeInfo>
         </items>
      </json>
   </results>
</query>
<!-- total: 646 -->
Copy to Clipboard Toggle word wrap

and the headers:

344.6. See Also

トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat