Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:28:24+00:00 2026-05-30T03:28:24+00:00

We use google-api-java-client to lookup videos and we would like to know if it

  • 0

We use google-api-java-client to lookup videos and we would like to know if it would be possible to fetch videos on a certain tag (say sports) published between certain dates (starting from yesterday till now). How do I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:28:27+00:00Added an answer on May 30, 2026 at 3:28 am

    I was able to do this using the google-api-client 1.6.0-beta (downloaded via Maven). I modified the example code a little. The API had changed slightly since the example code was written. I added query parameters from the YouTube API Reference Guide and extended the Video class to include a couple more fields. If you look at the raw JSON returned from the query you will see you could add several others fields including thumbnails, duration, aspect ratio, comment count etc. I hope this helps.

    import com.google.api.client.googleapis.GoogleHeaders;
    import com.google.api.client.googleapis.json.JsonCParser;
    import com.google.api.client.http.*;
    import com.google.api.client.http.javanet.NetHttpTransport;
    import com.google.api.client.json.JsonFactory;
    import com.google.api.client.json.jackson.JacksonFactory;
    import com.google.api.client.util.Key;
    import java.io.IOException;
    import java.util.List;
    
    public class YouTubeSample {
    
        public static class VideoFeed {
            @Key
            List<Video> items;
        }
    
        public static class Video {
            @Key
            String title;
            @Key
            String description;
            @Key
            Player player;
            @Key
            String uploaded;
            @Key
            String category;
            @Key
            String[] tags;
        }
    
        public static class Player {
            @Key("default")
            String defaultUrl;
        }
    
        public static class YouTubeUrl extends GenericUrl {
            @Key
            final String alt = "jsonc";
            @Key
            String author;
            @Key("max-results")
            Integer maxResults;
            @Key
            String category;        
            @Key
            String time;        
    
            YouTubeUrl(String url) {
                super(url);
            }
        }
    
        public static void main(String[] args) throws IOException {
            // set up the HTTP request factory
            HttpTransport transport = new NetHttpTransport();
            final JsonFactory jsonFactory = new JacksonFactory();
            HttpRequestFactory factory = transport.createRequestFactory(new HttpRequestInitializer() {
    
                @Override
                public void initialize(HttpRequest request) {
                    // set the parser
                    JsonCParser parser = new JsonCParser(jsonFactory);
                    request.addParser(parser);
                    // set up the Google headers
                    GoogleHeaders headers = new GoogleHeaders();
                    headers.setApplicationName("Google-YouTubeSample/1.0");
                    headers.gdataVersion = "2";
                    request.setHeaders(headers);
                }
            });
            // build the YouTube URL
            YouTubeUrl url = new YouTubeUrl("https://gdata.youtube.com/feeds/api/videos");
            url.maxResults = 10;
            url.category = "sports";        
            // Time options: today, this_week, this_month, all_time        
            url.time = "today";
    
    
            // build the HTTP GET request
            HttpRequest request = factory.buildGetRequest(url);
            // execute the request and the parse video feed
            VideoFeed feed = request.execute().parseAs(VideoFeed.class);
    
            // Useful for viewing raw JSON results
            //System.out.println(request.execute().parseAsString());
    
            for (Video video : feed.items) {
                System.out.println();
                System.out.println("Video title: " + video.title);
                System.out.println("Description: " + video.description);
                System.out.println("Play URL: " + video.player.defaultUrl);
                System.out.println("Uploaded: " + video.uploaded);
                System.out.println("Category: " + video.category);
                System.out.print("Tags: ");
                for(String tag: video.tags){
                    System.out.print(tag + " ");
                }
                System.out.println();
            }                    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use Google's places API. I downloaded google-api-java-client-1.6.0-beta.zip library and I'm
Hey All, I currently use Google's API to include jQuery into my sites like
I have recently started looking into Google Charts API for possible use within the
My goal is to understand every single bit of the following example: http://code.google.com/p/google-api-java-client/wiki/AndroidAccountManager I
I'm using the lightweight Google API Java client to modify contacts. There are a
How to use Google Transliteration API in my Java application. If i give a
I'm trying to use the Google Calendar API in my own Java class. Unfortunately,
I am now going to use the .jar file on http://code.google.com/p/google-api-translate-java/ . However, after
In this Gooogle IO 11 presentation - http://code.google.com/p/google-api-java-client/wiki/Android speaker has mentioned that new google-api-java-client
I know there is an unofficial Google Voice API for Java, but I couldn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.